logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
noumann  
#1 Posted : Thursday, May 30, 2019 3:44:33 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Hello everyone,

i found in a financial blog the formula for this indicator very useful to identify trends.It sound like Supertrend but it's slightly different.

Cold someone help me to translate it in metastock language?

Thank you in advance:

Code:
Var: VolaPer(2.2), Vola1(21), Vola2(10);

Var: HClose(-99999), LClose(99999), IndZona1, Value1(0), Value2, Ematrend, IdOggCross, vol(0), colore, Value2new(0);

vol = stddev(a, Vola1); Value1 = Op(constval(Volaper), Vol, Mul); HClose = IIF(C > HClose, C, HClose);  LClose = IIF(C < LClose, C, LClose);

If (Value2 = 0) and (CurrentBar <= 1) then Value2 = HClose - Value1 - ATR(C, Vola2); endif;

If (C < Value2) then Value2new = LClose + Value1 + ATR(C, Vola2); HClose = C; entershort(nextbar, atopen); Endif;

If (C > Value2) then Value2new = HClose - Value1 - ATR(C, Vola2); LClose = C; enterlong(nextbar, atopen); Endif;

Value2 = Value2new;

Indzona1 = CreateViewport(400, true, true); If (CurrentBar > 1) Then Ematrend = Value2[1]; PlotChart(Ematrend, 0, lime, solid, 2); endif;

if crossover(C, EMAtrend) Then colorbar(blue); IdOggCross = DrawText(IdOggCross, 0, D, H, "Bullish", C, green, 8, 1+4, 1); Endif;

if crossunder(C, EMAtrend) Then colorbar(maroon); IdOggCross = DrawText(IdOggCross, 0, D, H, "Bearish", C, red, 8, 1+4, 1); Endif;

If positiondir = 0 then colore = yellow; elseIf positiondir = 1 then colore = blue; elseif positiondir = -1 then colore = red; endif;

PlotChart(PositionDir, Indzona1, colore, solid, 2);

Edited by moderator Friday, May 31, 2019 3:09:46 PM(UTC)  | Reason: Cleaned up code formatting to make it easier to read

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.