My afl collection

Status
Not open for further replies.

sr114

Well-Known Member
Thank you sr114...but i am quite unaware about the programming language, so if you can help me out futher.?
one example is
ATR=Param("ATR Period",4,1,20,1);

this is used to change the ATR period in the code dynamically. so lot and param can be used in this way. read the help file and you will get the answer

sr
 

mehtaka

Active Member
one example is
ATR=Param("ATR Period",4,1,20,1);

this is used to change the ATR period in the code dynamically. so lot and param can be used in this way. read the help file and you will get the answer

sr
param function not helping me out.
Param function , i think its useful for the indicators.

I want to inpput the lot size of the two different tickers
 

sr114

Well-Known Member
param function not helping me out.
Param function , i think its useful for the indicators.

I want to inpput the lot size of the two different tickers
lots1=Param("Lot of T1",4,1,20,1); for ticker 1
lots2=Param("Lot of T2",4,1,20,1); for ticker 2

by this way in can put the code and dynamically change the lot size.

sr
 

mehtaka

Active Member
lots1=Param("Lot of T1",4,1,20,1); for ticker 1
lots2=Param("Lot of T2",4,1,20,1); for ticker 2

by this way in can put the code and dynamically change the lot size.

sr
No sucess...:(

I have put up this way..

_SECTION_BEGIN("spread");

lots1=Param("20",4,1,20,1);
lots2=Param("20",4,1,20,1);


spread = Foreign( "Goldm-1", "C") - Foreign( "Silverm-1", "C");
Plot( spread, "spread", colorRed);
_SECTION_END();

This is showing me ..normal Goldm-silverm
where as i want is closing price of goldm*20 - closing price of silverm*20

hope u got me?
 

sr114

Well-Known Member
No sucess...:(

I have put up this way..

_SECTION_BEGIN("spread");

lots1=Param("20",4,1,20,1);
lots2=Param("20",4,1,20,1);


spread = Foreign( "Goldm-1", "C") - Foreign( "Silverm-1", "C");
Plot( spread, "spread", colorRed);
_SECTION_END();

This is showing me ..normal Goldm-silverm
where as i want is closing price of goldm*20 - closing price of silverm*20

hope u got me?
u will never get it as the diff between goldm and silverm is 1:10 and also the lotsize to be incorporated in the actual plotting or u will never get the actual picture.

sr
 

shivangi77

Well-Known Member
Woodies CCI




Code:
Version(4.70); 
 
//MarketHours = TimeNum()>=63000 AND TimeNum()<=125959; 
 
//MArketClose= TimeNum()>=125959 AND TimeNum()<=130000; 
 
z = CCI(14); 
 
z6 = CCI(6); 
 
CCI50_var = CCI(50); 
 
LSMA25 = LinearReg(C, 25 ); 
 
EMA34 = EMA(C,34); 
 
PI = atan(1.00) * 4; 
 
periods = 30; 
 
HighHigh = HHV(H, periods); 
 
LowLow = LLV(L, periods); 
 
range = 25 / (HighHigh - LowLow) * LowLow; 
 
TTMperiod = 6; 
 
Low_ma = EMA(L, TTMperiod); 
 
High_ma = EMA(H, TTMperiod); 
 
Low_third = (High_ma - Low_ma) / 3 + Low_ma; 
 
High_third = 2 * (High_ma - Low_ma) / 3 + Low_ma; 
 
tempnum = Now( 4 ) - TimeNum(); 
 
TimeRem = Interval() - ((int(tempnum[BarCount - 1] / 100) * 60) + (tempnum[BarCount - 1] - int(tempnum[BarCount - 1] / 100) * 100)); 
 
if (TimeRem[BarCount - 1] < 0) TimeRem = 0; 
 
TitleTimeRem = EncodeColor(colorLightGrey) + "Time Remaining: "; 
 
MinuteVar = int(TimeRem / 60); 
 
SecondsVar = int(frac(TimeRem / 60) * 60); 
 
if (TimeRem[BarCount - 1] > 60) 
 
{ 
 
TitleTimeRem = TitleTimeRem + EncodeColor(colorWhite) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 
 
} 
 
else if (TimeRem[BarCount - 1] > 20) 
 
{ 
 
TitleTimeRem = TitleTimeRem + EncodeColor(colorYellow) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 
 
} 
 
else
 
{ 
 
TitleTimeRem = TitleTimeRem + EncodeColor(colorLime) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 
 
} 
 
if(SelectedValue(CCI50_var) < 0) 
 
{ 
 
CCI50Title = EncodeColor(colorRed); 
 
} 
 
else
 
{ 
 
CCI50Title = EncodeColor(colorLime); 
 
} 
 
CCI50Title = CCI50Title + "CCI 50 = " + round(CCI50_var) + ", "; 
 
stop_range = IIf(O < C, IIf((H - O) < (C - L), C - L, H - O), 
 
IIf((O - L) < (H - C), H - C, O - L)); 
 
StopTitle = EncodeColor(colorWhite) + "Stop = " + EncodeColor(colorYellow); 
 
StopTitle = StopTitle + StrToNum(NumToStr(stop_range, 4.4)); 
 
x1_EMA34 = 0; 
 
x2_EMA34 = 1; 
 
y1_EMA34 = 0; 
 
y2_EMA34 = (Ref(EMA34, -1) - EMA34) / Avg * range; 
 
c_EMA34 = sqrt((x2_EMA34 - x1_EMA34)*(x2_EMA34 - x1_EMA34) + (y2_EMA34 - y1_EMA34)*(y2_EMA34 - y1_EMA34)); 
 
angle_EMA34 = round(180 * acos((x2_EMA34 - x1_EMA34)/c_EMA34) / PI); 
 
TitleAngleEMA34 = EncodeColor(colorWhite) + "\nEMA34 angle = "; 
 
angle_EMA34 = IIf(y2_EMA34 > 0, - angle_EMA34, angle_EMA34); 
 
if(SelectedValue(angle_EMA34) >= 25) 
 
{ 
 
TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorTurquoise); 
 
} 
 
else if(SelectedValue(angle_EMA34) <= -25) 
 
{ 
 
TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorRed); 
 
} 
 
else if(SelectedValue(angle_EMA34) >= 5) 
 
{ 
 
TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorTurquoise); 
 
} 
 
else if(SelectedValue(angle_EMA34) <= -5) 
 
{ 
 
TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorRed); 
 
} 
 
else
 
{ 
 
TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorYellow); 
 
} 
 
TitleAngleEMA34 = TitleAngleEMA34 + angle_EMA34; 
 
x1_LSMA25 = 0; 
 
x2_LSMA25 = 1; 
 
y1_LSMA25 = 0; 
 
y2_LSMA25 = (Ref(LSMA25, -1) - LSMA25) / Avg * range; 
 
c_LSMA25 = sqrt((x2_LSMA25 - x1_LSMA25)*(x2_LSMA25 - x1_LSMA25) + (y2_LSMA25 - y1_LSMA25)*(y2_LSMA25 - y1_LSMA25)); 
 
angle_LSMA25 = round(180 * acos((x2_LSMA25 - x1_LSMA25)/c_LSMA25) / PI); 
 
TitleAngleLSMA25 = EncodeColor(colorWhite) + "LSMA25 angle = "; 
 
angle_LSMA25 = IIf(y2_LSMA25 > 0, - angle_LSMA25, angle_LSMA25); 
 
if(SelectedValue(angle_LSMA25) >= 25) 
 
{ 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorTurquoise); 
 
} 
 
else if(abs(SelectedValue(angle_LSMA25)) <= -25) 
 
{ 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorRed); 
 
} 
 
else if(SelectedValue(angle_LSMA25) >= 5) 
 
{ 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorTurquoise); 
 
} 
 
else if(SelectedValue(angle_LSMA25) <= -5) 
 
{ 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorRed); 
 
} 
 
else
 
{ 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorYellow); 
 
} 
 
TitleAngleLSMA25 = TitleAngleLSMA25 + angle_LSMA25; 
 
TitleTrending = WriteIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorLime) + "TRENDING", 
 
WriteIf((abs(angle_EMA34) >= 5) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 30), EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorYellow) + "NORMAL", 
 
EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorRed) + "FLAT")); 
 
SW = IIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), IIf(angle_LSMA25 > 0, 2, -2), 
 
IIf((abs(angle_EMA34) >= 5) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 30), IIf(angle_LSMA25 > 0, 1, -1), 0)); 
 
// Colour the bars for Woodies Trend Following 
 
Plusbars = BarsSince(z < 0); 
 
Minusbars = BarsSince(z > 0); 
 
TrendBarCount = 6; 
 
Color[0] = colorDefault; 
 
Trend[0] = 0; 
 
TTMColor[0] = colorDefault; 
 
for( i = 1; i < BarCount; i++ ) 
 
{ 
 
if (C[i] > High_third[i]) 
 
{ 
 
TTMColor[i] = colorDarkGreen; 
 
} 
 
else if (C[i] < Low_third[i]) 
 
{ 
 
TTMColor[i] = colorDarkRed; 
 
} 
 
else
 
{ 
 
TTMColor[i] = TTMColor[i - 1]; 
 
} 
 
if (Plusbars[i] >= TrendBarCount) 
 
{ 
 
Trend[i] = 1; 
 
} 
 
else if (Minusbars[i] >= TrendBarCount) 
 
{ 
 
Trend[i] = -1; 
 
} 
 
else
 
{ 
 
Trend[i] = Trend[i - 1]; 
 
} 
 
if (Trend[i] == 1) 
 
{ 
 
if (Minusbars[i] == TrendBarCount - 1) 
 
{ 
 
Color[i] = colorYellow; 
 
} 
 
else if (z[i] < 0) 
 
{ 
 
Color[i] = colorBlack; 
 
} 
 
else
 
{ 
 
Color[i] = colorLime; 
 
} 
 
} 
 
else if (Trend[i] == -1) 
 
{ 
 
if (Plusbars[i] == TrendBarCount - 1) 
 
{ 
 
Color[i] = colorYellow; 
 
} 
 
else if (z[i] >= 0) 
 
{ 
 
Color[i] = colorBlack; 
 
} 
 
else
 
{ 
 
Color[i] = colorRed; 
 
} 
 
} 
 
else
 
{ 
 
Color[i] = colorDefault; 
 
} 
 
} 
 
// CCI Line 
 
Plot(z,"CCI 14", colorBlack, styleLine | styleThick); 
 
// Turbo CCI 
 
Plot(z6,"CCI 6", colorDarkYellow, styleLine | styleNoLabel); 
 
// zero line 25lsma 
 
Plot(0,"", IIf(C > LSMA25,colorLime,IIf(C<LSMA25,colorRed,colorTeal)), 
 
styleDots | styleNoLine | styleThick | styleNoLabel); 
 
// CCI Histogram 
 
Plot(z,"", Color, styleHistogram | styleThick | styleNoLabel); 
 
// CCI 50 
 
//Plot(CCI50_var,"CCI 50", IIf(CCI50_var < 0, colorDarkRed,colorDarkGreen), styleLine | styleNoLabel); 
 
// Set up color for the 100s, green if 34ema above red if below 
 
//Color = IIf(C > EMA34, colorGreen, 
 
// IIf(C == EMA34, colorTeal, colorRed)); 
 
//Set Color for the SW 
 
ColorSW = IIf(abs(SW) == 2, colorLime, 
 
IIf(abs(SW) == 1, colorYellow, colorRed)); 
 
Color=colorWhite; 
 
// Plot the 100s 
 
//Plot(100,"",Color,styleDashed|styleNoLabel); 
 
//Plot(-100,"",Color,styleDashed|styleNoLabel); 
 
ColorANGLE_EMA = IIf(angle_EMA34 >=5, colorTurquoise, 
 
IIf(angle_EMA34 <=-5, colorRed, colorYellow)); 
 
//ColorANGLE_EMA1 = IIf(angle_EMA34 >=25, colorTurquoise, 
 
// IIf(angle_EMA34 <=-25, colorRed, colorBlack)); 
 
//ColorANGLE_EMA = IIf(abs(angle_EMA34) >=25, colorGreen, 
 
// IIf(abs(angle_EMA34) >=15, colorYellow, colorRed)); 
 
Plot(100,"", ColorANGLE_EMA , styleDashed | styleThick | styleNoLabel); 
 
Plot(-100,"", ColorANGLE_EMA , styleDashed | styleThick | styleNoLabel); 
 
// Plot the 50s 
 
Plot(50,"", colorDarkGrey, styleDashed | styleNoLabel); 
 
Plot(-50,"", colorDarkGrey , styleDashed | styleNoLabel); 
 
//Plot(50,"", TTMColor, styleDots | styleNoLine | styleNoLabel); 
 
//Plot(-50,"", TTMColor, styleDots | styleNoLine | styleNoLabel); 
 
// Plot the 200s 
 
Plot(200,"", ColorSW, styleThick | styleNoLabel); 
 
Plot(-200,"", ColorSW, styleThick | styleNoLabel); 
 
// Plot the grids 
 
PlotGrid(0); 
 
PlotGrid(50); 
 
PlotGrid(-50); 
 
PlotGrid(-100); 
 
PlotGrid(100); 
 
PlotGrid(-200); 
 
PlotGrid(200); 
 
// choppy 
 
A= (HHV(z,10)<=100 AND LLV(z,10)>=-100); 
 
B= (Ref(z,-1)>200 AND z<200) OR (Ref(z,-1)<-200 AND z>-200); 
 
bs_a=BarsSince(A); 
 
bs_b=BarsSince(B); 
 
bars = IIf( bs_A < Bs_B, bs_a, 0); 
 
// ZLR Long 
 
uptrend_a=BarsSince(z<0); 
 
uptrend_b=BarsSince(z>0); 
 
Linex_long=Ref(z,-1)>100 AND z<100; 
 
barsfromline_long=BarsSince(Linex_long); 
 
CCIhook_long=z>Ref(z,-1) AND Ref(z,-1)>-100 AND Ref(z,-1)<Ref(z,-2) AND Ref(z,-2)>-100 AND z>0; 
 
SW_trendinglong= sw==1 OR sw==2; 
 
zlrlong= (Ref(angle_ema34,-2)>=5 AND Ref(angle_ema34,-1)>=5 AND angle_ema34>=5) AND SW_trendinglong AND z<120 AND barsfromline_long<10 AND CCIhook_long AND (uptrend_a>=6 AND z>-100 OR
 
(uptrend_b<6 AND LLV(z,uptrend_b)>-100 AND z>-100 AND (Ref(uptrend_a,-6)>=6 AND z>-100 OR Ref(uptrend_a,-5)>=6 AND z>-100 OR Ref(uptrend_a,-4)>=6 AND z>-100 OR Ref(uptrend_a,-3)>=6 AND z>-100 OR
 
Ref(uptrend_a,-2)>=6 AND z>-100 OR Ref(uptrend_a,-1)>=6 AND z>-100))); 
 
PlotShapes(IIf(zlrlong,shapeDigit1,shapeNone),colorLime,0,0,-15); 
 
// ZLR Short 
 
downtrend_a=BarsSince(z>0); 
 
downtrend_b=BarsSince(z<0); 
 
Linex_short=Ref(z,-1)<=-100 AND z>=-100; 
 
barsfromline_short=BarsSince(Linex_short); 
 
CCIhook_short=z<Ref(z,-1) AND Ref(z,-1)<100 AND Ref(z,-1)>Ref(z,-2) AND Ref(z,-2)<100 AND z<0; 
 
SW_trendingshort= sw==-1 OR sw==-2; 
 
zlrshort= (Ref(angle_ema34,-2)<=-5 AND Ref(angle_ema34,-1)<=-5 AND angle_ema34<=-5) AND SW_trendingshort AND z>-120 AND barsfromline_short<10 AND CCIhook_short AND (downtrend_a>=6 AND z<100 OR
 
(downtrend_b<6 AND HHV(z,downtrend_b)<100 AND z<100 AND (Ref(downtrend_a,-6)>=6 AND z<100 OR Ref(downtrend_a,-5)>=6 AND z<100 OR Ref(downtrend_a,-4)>=6 AND z<100 OR
 
Ref(downtrend_a,-3)>=6 AND z<100 OR Ref(downtrend_a,-2)>=6 AND z<100 OR Ref(downtrend_a,-1)>=6 AND z<100))); 
 
PlotShapes(IIf(zlrshort,shapeDigit1+ shapePositionAbove,shapeNone),colorRed,0,0,-15); 
 
// Famir Short 
 
Famir_downtrend_a=BarsSince(z<0); 
 
Famir_downtrend_b=BarsSince(z>0); 
 
FamirLinex_short=Ref(z,-1)>=100 AND z<100; 
 
Famir_barsfromline_short=BarsSince(FamirLinex_short); 
 
Famir_pivotshort= (Ref(z,-2)<Ref(z,-1)AND Ref(z,-1)<=55 AND Ref(z,-2)<=55) OR (Ref(z,-3)<Ref(z,-1)AND Ref(z,-1)<=55 AND Ref(z,-2)<=55 AND Ref(z,-3)<=55) 
 
OR (Ref(z,-4)<Ref(z,-1) AND Ref(z,-1)<=55 AND Ref(z,-2)<=55 AND Ref(z,-3)<=55); 
 
Famirhook_short=Famir_pivotshort AND z<Ref(LLV(z,Famir_barsfromline_short),-1) AND (z>=-55 AND z<=55) AND C<Lsma25; 
 
Famirshort=  Famir_barsfromline_short<10 AND Famirhook_short AND (Famir_downtrend_a>=6 OR
 
(Famir_downtrend_b<6 AND (Ref(Famir_downtrend_a,-6)>=6 OR Ref(Famir_downtrend_a,-5)>=6 OR Ref(Famir_downtrend_a,-4)>=6 OR
 
Ref(Famir_downtrend_a,-3)>=6 OR Ref(Famir_downtrend_a,-2)>=6 OR Ref(Famir_downtrend_a,-1)>=6))) AND C<LSMA25; 
 
PlotShapes(IIf(famirShort,shapeDigit2+ shapePositionAbove,shapeNone),colorRed,0,0,-15); 
 
// Famir Long 
 
Famir_uptrend_a=BarsSince(z<0); 
 
Famir_uptrend_b=BarsSince(z>0); 
 
FamirLinex_long=Ref(z,-1)<=-100 AND z>-100; 
 
Famir_barsfromline_long=BarsSince(FamirLinex_long); 
 
Famir_pivotlong= (Ref(z,-2)>Ref(z,-1)AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55) OR (Ref(z,-3)>Ref(z,-1) AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55 AND Ref(z,-3)>=-55) 
 
OR (Ref(z,-4)>Ref(z,-1) AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55 AND Ref(z,-3)>=-55); 
 
Famirhook_long=Famir_pivotlong AND z>Ref(HHV(z,Famir_barsfromline_long),-1) AND (z>=-55 AND z<=55) AND C>Lsma25; 
 
Famirlong= Famir_barsfromline_long<10 AND Famirhook_long AND (Famir_uptrend_a<6 OR
 
(Famir_uptrend_b>=6 AND(Ref(Famir_uptrend_a,-6)<6 OR Ref(Famir_uptrend_a,-5)<6 OR Ref(Famir_uptrend_a,-4)<6 OR Ref(Famir_uptrend_a,-3)<6 OR
 
Ref(Famir_uptrend_a,-3)<6 OR Ref(Famir_uptrend_a,-2)<6 OR Ref(Famir_uptrend_a,-1)<6))) AND C>LSMA25; 
 
PlotShapes(IIf(famirlong,shapeDigit2,shapeNone),colorLime,0,0,-15); 
 
// HFE 
 
HFEshort=(Ref(z,-1)>200 AND z<200); 
 
HFElong=(Ref(z,-1)<-200 AND z>-200); 
 
HFE= (Ref(z,-1)>200 AND z<200) OR (Ref(z,-1)<-200 AND z>-200); 
 
PlotShapes(IIf(Ref(z,-1)>200 AND z<200,shapeDownTriangle,shapeNone),IIf(Ref(z,-1)>200 AND z<200,colorYellow,shapeNone),0,200,-20); 
 
PlotShapes(IIf(Ref(z,-1)<-200 AND z>-200,shapeUpTriangle,shapeNone),IIf(Ref(z,-1)<-200 AND z>-200,colorYellow,shapeNone),0,-200,-20); 
 
// VT Long 
 
vtLinex_long=Ref(z,-1)<=-200 AND z>-200; 
 
vt_barsfromline_long=BarsSince(vtLinex_long); 
 
vtlong_A = z<-200; 
 
vtlong_B = Ref(z,-1)<=Ref(z,-2) OR
 
Ref(z,-2)<=Ref(z,-3) OR
 
Ref(z,-3)<=Ref(z,-4) OR
 
Ref(z,-4)<=Ref(z,-5) OR
 
Ref(z,-5)<=Ref(z,-6) OR
 
Ref(z,-6)<=Ref(z,-7) OR
 
Ref(z,-7)<=Ref(z,-8); 
 
vtlong_bs_A = BarsSince(vtlong_A); 
 
vtlong_bs_B = BarsSince(vtlong_b); 
 
Vtlong_bars = vtlong_bs_A>=5 AND vtlong_bs_B<=0; 
 
vt_pivotlong= Vtlong_bars; 
 
swinghibars=BarsSince(z>Ref(HHV(z,vt_barsfromline_long),-1)); 
 
vthook_long= vt_pivotlong AND z>Ref(HHV(z,vt_barsfromline_long),-1); 
 
vtlong= vt_barsfromline_long<=11 AND (Ref(HHV(z,vt_barsfromline_long),-1)<0 OR HHV(z,vt_barsfromline_long)<=0) AND vthook_long AND C>Lsma25 AND Ref(swinghibars>=2,-1) AND z>-100; 
 
PlotShapes(IIf(vtlong,shapeDigit3,shapeNone),colorLime,0,Min(z,0),-45); 
 
// VT Short 
 
vtLinex_short=Ref(z,-1)>=200 AND z<200; 
 
vt_barsfromline_short=BarsSince(vtLinex_short); 
 
vtshort_A = z>200 ; 
 
vtshort_B =Ref(z,-1)>=Ref(z,-2) OR
 
Ref(z,-2)>=Ref(z,-3) OR
 
Ref(z,-3)>=Ref(z,-4) OR
 
Ref(z,-4)>=Ref(z,-5) OR
 
Ref(z,-5)>=Ref(z,-6) OR
 
Ref(z,-6)>=Ref(z,-7) OR
 
Ref(z,-7)>=Ref(z,-8); 
 
vtshort_bs_A = BarsSince(vtshort_A); 
 
vtshort_bs_B = BarsSince(vtshort_b); 
 
Vtshort_bars = vtshort_bs_A>=5 AND vtshort_bs_B<=0; 
 
vt_pivotshort= Vtshort_bars; 
 
swinglowbars= BarsSince(z<Ref(LLV(z,vt_barsfromline_short),-1)); 
 
vthook_short= vt_pivotshort AND z<Ref(LLV(z,vt_barsfromline_short),-1); 
 
vtshort= vt_barsfromline_short<=11 AND (Ref(LLV(z,vt_barsfromline_short),-1)>0 OR LLV(z,vt_barsfromline_short)>0) AND vthook_short AND C<Lsma25 AND Ref(swinglowbars>=2,-1) AND z<100; 
 
PlotShapes(IIf(vtshort,shapeDigit3+ shapePositionAbove,shapeNone),colorRed,0,Max(z,0),-45); 
 
// GB 100 Long 
 
uptrend_a=BarsSince(z<0); 
 
uptrend_b=BarsSince(z>0); 
 
Linex_longGB=Ref(z,-1)>100 AND z<100; 
 
barsfromline_longGB=BarsSince(Linex_longGB); 
 
CCIhook_longGB= Ref(z,-1)<-100 AND z>-100; 
 
GB100long= barsfromline_longGB<20 AND angle_EMA34>=5 AND CCIhook_longGB AND (uptrend_b<6 AND(Ref(uptrend_a,-6)>=6 OR Ref(uptrend_a,-5)>=6 OR Ref(uptrend_a,-4)>=6 OR Ref(uptrend_a,-3)>=6 OR
 
Ref(uptrend_a,-2)>=6 OR Ref(uptrend_a,-1)>=6)); 
 
PlotShapes(IIf(GB100long,shapeDigit4,shapeNone),colorLime,0,0,-60); 
 
// GB100 Short 
 
downtrend_a=BarsSince(z>0); 
 
downtrend_b=BarsSince(z<0); 
 
Linex_shortGB=Ref(z,-1)<-100 AND z>-100; 
 
barsfromline_shortGB=BarsSince(Linex_shortGB); 
 
CCIhook_shortGB=Ref(z,-1)>100 AND z<100; 
 
GB100short= barsfromline_shortGB<20 AND angle_EMA34<=-5 AND CCIhook_shortGB AND
 
(downtrend_b<6 AND (Ref(downtrend_a,-6)>=6 OR Ref(downtrend_a,-5)>=6 OR Ref(downtrend_a,-4)>=6 OR
 
Ref(downtrend_a,-3)>=6 OR Ref(downtrend_a,-2)>=6 OR Ref(downtrend_a,-1)>=6)); 
 
PlotShapes(IIf(GB100short,shapeDigit4+ shapePositionAbove,shapeNone),colorRed,0,0,-60); 
 
// MR Long 
 
MRuptrend_a=BarsSince(z<0); 
 
MRuptrend_b=BarsSince(z>0); 
 
MRLinex_long=Ref(z,-1)>100 AND z<100; 
 
MRbarsfromline_long=BarsSince(MRLinex_long); 
 
MRCCIhook_long=z>Ref(z,-1) AND Ref(z,-1)<=Ref(z,-2) AND Ref(z,-2)<Ref(z,-3) AND z>-100 AND z<100; 
 
MRlong= (Ref(angle_ema34,-2)>=5 AND Ref(angle_ema34,-1)>=5 AND angle_ema34>=5) AND Ref(z,-1)<=0 AND MRCCIhook_long AND (MRuptrend_a>=6 AND z>-100 OR
 
(MRuptrend_b<6 AND LLV(z,MRuptrend_b)>-100 AND z>-100 AND (Ref(MRuptrend_a,-6)>=6 AND z>-100 OR Ref(MRuptrend_a,-5)>=6 AND z>-100 OR Ref(MRuptrend_a,-4)>=6 AND z>-100 OR Ref(MRuptrend_a,-3)>=6 AND z>-100 OR
 
Ref(MRuptrend_a,-2)>=6 AND z>-100 OR Ref(MRuptrend_a,-1)>=6 AND z>100))); 
 
PlotShapes(IIf(MRlong,shapeDigit5,shapeNone),colorLime,0,0,-50); 
 
// MR Short 
 
MRdowntrend_a=BarsSince(z>0); 
 
MRdowntrend_b=BarsSince(z<0); 
 
MRLinex_short=Ref(z,-1)<=-100 AND z>=-100; 
 
MRbarsfromline_short=BarsSince(MRLinex_short); 
 
MRCCIhook_short=z<Ref(z,-1) AND Ref(z,-1)>=Ref(z,-2) AND Ref(z,-2)>Ref(z,-3) AND z<100 AND z>-100; 
 
MRshort= (Ref(angle_ema34,-2)<=-5 AND Ref(angle_ema34,-1)<=-5 AND angle_ema34<=-5) AND Ref(z,-1)>=0 AND MRCCIhook_short AND (MRdowntrend_a>=6 AND z<100 OR
 
(MRdowntrend_b<6 AND HHV(z,MRdowntrend_b)<100 AND z<100 AND (Ref(MRdowntrend_a,-6)>=6 AND z<100 OR Ref(MRdowntrend_a,-5)>=6 AND z<100 OR Ref(MRdowntrend_a,-4)>=6 AND z<100 OR
 
Ref(MRdowntrend_a,-3)>=6 AND z<100 OR Ref(MRdowntrend_a,-2)>=6 AND z<100 OR Ref(MRdowntrend_a,-1)>=6 AND z<100))); 
 
PlotShapes(IIf(MRshort,shapeDigit5+ shapePositionAbove,shapeNone),colorRed,0,0,-50);
 
// Columns for exploration 
 
Filter =(zlrlong OR famirlong OR Vtlong OR gb100long OR mrlong  OR hfe OR zlrshort OR famirshort OR vtshort OR gb100short OR mrlong OR (A OR bars)) AND 1 ; 
 
Buy = (zlrlong OR famirlong OR Vtlong OR gb100long OR mrlong);// AND MarketHours; 
 
Sell= (z<Ref(z,-1) AND Ref(z,-1)<Ref(z,-2) AND C<O);// OR MArketClose; ; 
 
Short = (zlrshort OR famirshort OR Vtshort OR gb100short OR mrshort); //AND MarketHours; 
 
Cover = (z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2) AND C>O);// OR MArketClose; 
 
AddColumn( IIf(zlrlong,1,IIf(zlrshort,-1,0)) ,"ZLR",1.0,colorWhite,IIf(zlrlong,colorGreen,IIf(zlrshort,colorRed,colorBlack))); 
 
AddColumn(IIf(famirlong,1,IIf(famirShort,-1,0)),"Famir",1.0,colorWhite,IIf(famirlong,colorGreen,IIf(famirShort,colorRed,colorBlack))); 
 
AddColumn(IIf(vtlong,1,IIf(vtShort,-1,0)),"Vegas",1.0,colorWhite,IIf(vtlong,colorGreen,IIf(vtShort,colorRed,colorBlack))); 
 
AddColumn(IIf(gb100long,1,IIf(gb100Short,-1,0)),"GB100",1.0,colorWhite,IIf(gb100long,colorGreen,IIf(gb100Short,colorRed,colorBlack))); 
 
AddColumn( IIf(mrlong,1,IIf(mrShort,-1,0)) ,"MR",1.0,colorWhite,IIf(mrlong,colorGreen,IIf(mrShort,colorRed,colorBlack))); 
 
AddColumn(IIf(hfelong,1,IIf(hfeshort,-1,0)),"HFE",1.0,colorWhite,IIf(hfelong,colorGreen,IIf(hfeshort,colorRed,colorBlack))); 
 
AddColumn(IIf(A OR bars,1,IIf(A OR bars,-1,0)),"Choppy",1.0,colorWhite,IIf(A OR bars,colorDarkYellow,IIf(A OR bars,colorDarkYellow,colorBlack))); 
 
//Plot Sell Arrows 
 
//Sell1=ExRem(Sell,Buy); 
 
//Cover1=ExRem(Cover,Short); 
 
//PlotShapes(IIf(Sell1,shapeDownArrow,shapeNone),colorLime,0,200,10); 
 
//PlotShapes(IIf(Cover1,shapeDownArrow,shapeNone),colorRed,0,200,10); 
 
//Signal Title 
 
Signaltitle= WriteIf(zlrlong,EncodeColor(colorYellow) + "ZLR ", 
 
WriteIf(zlrshort,EncodeColor(colorYellow) + "ZLR ", WriteIf(MRShort,EncodeColor(colorYellow) + "MR ", 
 
WriteIf(MRlong,EncodeColor(colorYellow) + "MR ", 
 
WriteIf(Famirshort,EncodeColor(colorYellow) + "FAMIR ", 
 
WriteIf(Famirlong,EncodeColor(colorYellow) + "FAMIR ",WriteIf(HFE,EncodeColor(colorYellow) + "HFE ",WriteIf(VTlong,EncodeColor(colorYellow) + "VT ", 
 
WriteIf(VTshort,EncodeColor(colorYellow) + "VT ",WriteIf(GB100long,EncodeColor(colorYellow) + "GB100 ", 
 
WriteIf(Gb100short,EncodeColor(colorYellow) + "GB100 "," "))))))))))); 
 
//Choppy Title 
 
ChoppyTitle= WriteIf(A,EncodeColor(colorYellow) + "CHOPPY",WriteIf(bars,EncodeColor(colorYellow) + "CHOPPY","")); 
 
//Exit Title 
 
//Exittitle=WriteIf(Sell1,EncodeColor(colorLime) + "MLAY EXIT LONG",WriteIf(Cover1,EncodeColor(colorRed) + "MPLAY EXIT SHORT","")); 
 
//Distance from EMA34
 
//Ctoema=round(C-EMA34);
 
//Ctitle= WriteIf(Ctoema>0," points above EMA,",WriteIf(Ctoema<0," points below EMA,"," on EMA,"));
 
//Number of trending bars
 
//anglelimit= ( angle_ema34<5 AND angle_ema34>-5)  OR (angle_ema34<5 AND angle_ema34>-5);
 
//angletitle= BarsSince(anglelimit);
 
// Price Panel
 
Lastprice=Ref(C,-1);
 
Lastpricetitlehi= WriteIf(H>Ref(H,-1),EncodeColor(colorLime) + Ref(H,-1) + "  " + H , EncodeColor(colorBlack)+ Ref(H,-1) + "  " + H);
 
Lastpricetitlelo= WriteIf(L<Ref(L,-1),EncodeColor(colorRed) + Ref(L,-1) + "  " + L , EncodeColor(colorBlack)+ Ref(L,-1) + "  " + L);
 
//Title 
 
Title = "" + Name() + ", " + Interval(2) + ", " + Date() + "\n" + 
 
//EncodeColor(colorBlack) + "CCI 14 = " + round(z) + EncodeColor(colorWhite) + ", " + EncodeColor(colorDarkYellow) + 
 
//"CCI 6 = " + round(z6) + EncodeColor(colorWhite) + ", " + 
 
TitleTimeRem + EncodeColor(colorWhite) + 
 
TitleAngleEMA34 +// EncodeColor(colorWhite) + ", " + TitleAngleLSMA25 + 
 
TitleTrending + "\n" + Lastpricetitlehi + "\n" + EncodeColor(colorSkyblue) + C + "\n" + Lastpricetitlelo + "\n" +
 
EncodeColor(colorWhite)+"Signal = "+Signaltitle + ChoppyTitle; //+ EncodeColor(colorWhite) + Ctoema + Ctitle +  EncodeColor(colorWhite) + " " + angletitle + " " + "bars trending, " + "  " + " "+Exittitle; 
 
//Mplay Exit 
 
MplayExitLong= z<Ref(z,-1) AND Ref(z,-1)<Ref(z,-2) AND C<O; 
 
MplayExitShort= z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2) AND C>O; 
 
PlotShapes(IIf(MplayExitLong,shapeSmallCircle,shapeNone),colorLime,0,200,-10); 
 
PlotShapes(IIf(MplayExitShort,shapeSmallCircle,shapeNone),colorRed,0,200,-10); 
_SECTION_END();
 
....
another implementation is using the fractal which can clearly depicts the different situation of HH,LL,HL or LH. some may think that it is future looking but the concept is that newer data set of prices are coming which is higher that previous set or lower than the previous set. or equal to the it. so depending on this the piv are formed and this gives a clear signal what are the pivs.

so it clearly depends upon u to follow what method but the main thing is that the generation of the boxex means a price reversal

picture speaks for itself


sr
Dear sr114,

My attention was triggered by your image posted in the Nirvana thread. This seems to be a fractal-based HH/HL indicator (with autotrendlines..). It maybe a rude question but could you please share this AFL?

Thanks in advance!
 

sr114

Well-Known Member
TechTradeRookie

yes i can share the afl.

in what sense you are going to use this afl?
why are you so interested in this afl?

i am waitin for your reply buddy. here goes the afl

_SECTION_BEGIN("Trendlines Multitimeframe");
// Amibroker AFL code by Edward Pottasch, 6/8/2011
// Using fractals to create automatic trendlines
// Using option to show multiple timeframes
Version(5.21);
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",3,2,50,1);
tf=Param("Time Frame (min)",5,1,100000,1);tfrm=in1Minute*tf;
CleanPivots=ParamToggle("Use Clean Pivots","Off|On",0);
PivotSymmetry=ParamToggle("Use Symmetric Pivots","Off|On",0);
tld=ParamToggle("All trendlines","Show|Hide",1);
showSignals=ParamToggle("Display signals","Off|On",0);

TimeFrameSet(tfrm);
if (PivotSymmetry)
{
fc=1;
pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}
else
{
fc=2;
pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}
px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
if (CleanPivots)
{
tr=IIf(pk AND tr AND ph1>ph2 AND tl1>tl2,False,tr);
pk=IIf(pk AND tr AND ph1<ph2 AND tl1<tl2,False,pk);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND ph1<tl1,False,pk);
tr=IIf(tr AND tx1>px1 AND tl1>ph1,False,tr);
pk=IIf(pk AND px0<tx0 AND ph0>ph1,False,pk);
tr=IIf(tr AND px0>tx0 AND tl0<tl1,False,tr);
pk=IIf(pk AND px2>tx1 AND ph1<=ph2,False,pk);
tr=IIf(tr AND tx2>px1 AND tl1>=tl2,False,tr);
pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);
tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0<tl1,False,tr);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND ph1<tl1,False,pk);
tr=IIf(tr AND tx1>px1 AND tl1>ph1,False,tr);
pk=IIf(pk AND px0<tx0 AND ph0>ph1,False,pk);
tr=IIf(tr AND px0>tx0 AND tl0<tl1,False,tr);
pk=IIf(pk AND px2>tx1 AND ph1<=ph2,False,pk);
tr=IIf(tr AND tx2>px1 AND tl1>=tl2,False,tr);
pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);
tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0<tl1,False,tr);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND px2>tx1 AND ph1<ph2,False,pk);
tr=IIf(tr AND tx1>px1 AND tx2>px1 AND tl1>tl2,False,tr);
}
pkh=IIf(pk,H,Null);
trl=IIf(tr,L,Null);
TimeFrameRestore();
fact=Max(tfrm/60,Interval()/60)/(Interval()/60);
Lkbk=tfrm/Interval();
if(Lkbk>1)
{
pk=TimeFrameExpand(pk,tfrm,expandFirst);
pkh=TimeFrameExpand(pkh,tfrm,expandFirst);
pkhs=IIf(!IsEmpty(pkh),1,0);pkhs=pkhs-Ref(pkhs,-1);
pk=pk AND H==pkh;
cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;
pk=pk AND cond1;

tr=TimeFrameExpand(tr,tfrm,expandFirst);
trl=TimeFrameExpand(trl,tfrm,expandFirst);
trls=IIf(!IsEmpty(trl),1,0);trls=trls-Ref(trls,-1);
tr=tr AND L==trl;
cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;
tr=tr AND cond1;

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
}
y0=ValueWhen(tr,trl,0);
y1=ValueWhen(tr,trl,1);
y2=ValueWhen(tr,trl,2);
y3=ValueWhen(tr,trl,3);
x0=ValueWhen(tr,xx,0);
x1=ValueWhen(tr,xx,1);
x2=ValueWhen(tr,xx,2);
x3=ValueWhen(tr,xx,3);

aa=(Y0-Y1)/(X0-X1);
ls1=aa*(xx-X1)+Y1;
dls1=ls1-Ref(ls1,-1);
aa=(Y1-Y2)/(X1-X2);
ls2=aa*(xx-X1)+Y1;
dls2=ls2-Ref(ls2,-1);
dls2=IIf(tr,Ref(dls1,-1),dls2);
aa=(Y2-Y3)/(X2-X3);
ls3=aa*(xx-X2)+Y2;
dls3=ls3-Ref(ls3,-1);
dls3=IIf(tr,Ref(dls2,-1),dls3);
y0=ValueWhen(pk,pkh,0);
y1=ValueWhen(pk,pkh,1);
y2=ValueWhen(pk,pkh,2);
y3=ValueWhen(pk,pkh,3);
x0=ValueWhen(pk,xx,0);
x1=ValueWhen(pk,xx,1);
x2=ValueWhen(pk,xx,2);
x3=ValueWhen(pk,xx,3);
aa=(Y0-Y1)/(X0-X1);
hs1=aa*(xx-X1)+Y1;
dhs1=hs1-Ref(hs1,-1);
aa=(Y1-Y2)/(X1-X2);
hs2=aa*(xx-X1)+Y1;
dhs2=hs2-Ref(hs2,-1);
dhs2=IIf(pk,Ref(dhs1,-1),dhs2);
aa=(Y2-Y3)/(X2-X3);
hs3=aa*(xx-X2)+Y2;
dhs3=hs3-Ref(hs3,-1);
dhs3=IIf(pk,Ref(dhs2,-1),dhs3);
if (tld)
{
dd=0.0;
Vh=dd*(ValueWhen(pk,C)-ValueWhen(pk,Ref(C,-1)))/ValueWhen(pk,C);
Vl=dd*(ValueWhen(tr,C)-ValueWhen(tr,Ref(C,-1)))/ValueWhen(tr,C);
ls1=IIf(dls1>=Vl,ls1,Null);
ls2=IIf(dls2>=Vl,ls2,Null);
ls3=IIf(dls3>=Vl,ls3,Null);
hs1=IIf(dhs1<=Vh,hs1,Null);
hs2=IIf(dhs2<=Vh,hs2,Null);
hs3=IIf(dhs3<=Vh,hs3,Null);
}
ls2a=IIf(BarsSince(tr)<=nbar*fact,ls2,Null);
ls2b=IIf(BarsSince(tr)>nbar*fact,ls2,Null);
ls3=IIf(BarsSince(tr)<=nbar*fact,ls3,Null);
hs2a=IIf(BarsSince(pk)<=nbar*fact,hs2,Null);
hs2b=IIf(BarsSince(pk)>nbar*fact,hs2,Null);
hs3=IIf(BarsSince(pk)<=nbar*fact,hs3,Null);
_SECTION_END();

_SECTION_BEGIN("Chart Colors");
SetChartBkColor(ParamColor("Background Color",ColorRGB(0,0,0)));
SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"Close",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

Plot(pkh,"",colorRed,styleThick,0,0,0,-1);
Plot(trl,"",colorBrightGreen,styleThick,0,0,0,-1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>nbar*fact,ColorRGB(128,255,128),colorWhite),0,L,-10); // change RGB(0,100,0) by RGB(128,255,128)
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>nbar*fact,ColorRGB(255,0,0),colorWhite),0,H,10);
Plot(ls1,"\nLower Trendline",colorBrightGreen,styleLine,0,0,0,-1);
Plot(ls2a,"",colorLightGrey,styleNoLine|styleDots| styleThick,0,0,0,-1);
Plot(ls2b,"",colorBrightGreen,styleNoLine|styleDots| styleThick,0,0,0,-1);
Plot(ls3,"",colorBrightGreen,styleNoLine|styleDots|styleThick,0,0,0,-1);
Plot(hs1,"\nUpper Trendline",colorRed,styleLine,0,0,0,-1);
Plot(hs2a,"",colorLightGrey,styleNoLine|styleDots| styleThick,0,0,0,-1);
Plot(hs2b,"",colorOrange,styleNoLine|styleDots|styleThick,0,0,0,-1);
Plot(hs3,"",colorOrange,styleNoLine|styleDots|styleThick,0,0,0,-1);
_SECTION_END();

if(showSignals)
{
Buy=( (!IsEmpty(Ref(hs2b,-1)) AND Ref(C<hs2b,-1)) AND (!IsEmpty(hs2b) AND C>hs2b) )
OR ( (!IsEmpty(Ref(hs3,-1)) AND Ref(C<hs3,-1)) AND (!IsEmpty(hs3) AND C>hs3) )
OR ( (!IsEmpty(Ref(hs2b,-1)) AND Ref(C<hs2b,-1)) AND (!IsEmpty(hs3) AND C>hs3) );
Buy=ExRem(Buy,tr OR pk);
BuyPrice=C;

Short=( (!IsEmpty(Ref(ls2b,-1)) AND Ref(C>ls2b,-1)) AND (!IsEmpty(ls2b) AND C<ls2b) )
OR ( (!IsEmpty(Ref(ls3,-1)) AND Ref(C>ls3,-1)) AND (!IsEmpty(ls3) AND C<ls3) )
OR ( (!IsEmpty(Ref(ls2b,-1)) AND Ref(C>ls2b,-1)) AND (!IsEmpty(ls3) AND C<ls3) );
Short=ExRem(Short,tr OR pk);
ShortPrice=C;
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBrightGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
PlotShapes(IIf(Short,shapeSmallDownTriangle,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Short,shapeSmallCircle,shapeNone),colorWhite,0,ShortPrice,0);
}

qq=Interval()/60;
if(qq < 60){tf=" min";tt=qq;}
else if(qq >= 60 AND qq < 1440){tf=" hrs";tt=qq/60;}
else if(qq >= 1440){tf=" days";tt=(qq/60)/24;}
qq=Max(tfrm/60,Interval()/60);
if(qq < 60){tfa=" min";tta=qq;}
else if(qq >= 60 AND qq < 1440){tfa=" hrs";tta=qq/60;}
else if(qq >= 1440){tfa=" days";tta=(qq/60)/24;}

Title = EncodeColor(colorWhite)+ Name() + EncodeColor(colorWhite)+
"\nNbar: " + nbar +
"\nChart TF: " + tt + tf +
"\nTrend TF: " + tta + tfa;
_SECTION_END();

_SECTION_BEGIN("Label");
disp=ParamToggle("Display labels","Off|On",1);
dxhm=Param("Shift X Highs (Margin)",14,-100,100,1);
dxlm=Param("Shift X Lows (Margin)",10,-100,100,1);
dxh=Param("Shift X Highs",0,-100,100,1);
dxl=Param("Shift X Lows",0,-100,100,1);
dyhm=Param("Shift Y Highs (Margin)",5,-100,100,1);
dylm=Param("Shift Y Lows (Margin)",3,-100,100,1);
dyh=Param("Shift Y Highs",18,-100,100,1);
dyl=Param("Shift Y Lows",29,-100,100,1);
hm=Param("Marging High",30,-100,100,1);
lm=Param("Margin Low",30,-100,100,1);

function GetVisibleBarCount()
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertPixelsToBarX(Pixels)
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
pxchartleft=Status("pxchartleft");
pxchartwidth=Status("pxchartwidth");
fac=pxchartwidth/Pixels;
bar=(lvb-fvb)/fac;
return bar;
}
function GfxConvertPixelToValueY(Pixels)
{
local Miny,Maxy,pxchartbottom,pxchartheight;
Miny=Status("axisminy");
Maxy=Status("axismaxy");
pxchartbottom=Status("pxchartbottom");
pxchartheight=Status("pxchartheight");
fac=pxchartheight/Pixels;
Value=(Maxy-Miny)/fac;
return Value;
}
if(disp)
{
ll=tr AND tl1<tl2;
hl=tr AND tl1>tl2;
hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2;
dt=pk AND ph1==ph2;
db=tr AND tl1==tl2;

PlotShapes(shapeHollowCircle*lh,ColorRGB(255,193,193),0,H,10);
PlotShapes(shapeHollowCircle*hl,ColorRGB(202,255,112),0,L,-10);

miny=Status("axisminy");
maxy=Status("axismaxy");
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
LowMargin=Miny+GfxConvertPixelToValueY(lm);
HighMargin=Maxy-GfxConvertPixelToValueY(hm);
dyllm=GfxConvertPixelToValueY(dylm);
dyhhm=GfxConvertPixelToValueY(dyhm);
dyll=GfxConvertPixelToValueY(dyl);
dyhh=GfxConvertPixelToValueY(dyh);
dxllm=GfxConvertPixelsToBarX(dxlm);
dxhhm=GfxConvertPixelsToBarX(dxhm);
dxll=GfxConvertPixelsToBarX(dxl);
dxhh=GfxConvertPixelsToBarX(dxh);

for(i=0;i<AllVisibleBars;i++)
{
if(ll[i+fvb] AND L[i+fvb]>LowMargin)
PlotText("L L",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
if(ll[i+fvb] AND L[i+fvb]<=LowMargin)
PlotText("L L",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
if(hl[i+fvb] AND L[i+fvb]>LowMargin)
PlotText("HL",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
if(hl[i+fvb] AND L[i+fvb]<=LowMargin)
PlotText("HL",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
if(db[i+fvb] AND L[i+fvb]>LowMargin)
PlotText("DB^",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
if(db[i+fvb] AND L[i+fvb]<=LowMargin)
PlotText("DB^",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
if(hh[i+fvb] AND H[i+fvb]<HighMargin)
PlotText("HH",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
if(hh[i+fvb] AND H[i+fvb]>=HighMargin)
PlotText("HH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
if(lh[i+fvb] AND H[i+fvb]<HighMargin)
PlotText("LH",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
if(lh[i+fvb] AND H[i+fvb]>=HighMargin)
PlotText("LH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
if(dt[i+fvb] AND H[i+fvb]<HighMargin)
PlotText("DTv",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
if(dt[i+fvb] AND H[i+fvb]>=HighMargin)
PlotText("DTv",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
}
Plot(tr,"",ColorRGB(0,100,0),styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);
Plot(pk,"",ColorRGB(100,0,0),styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);

}
_SECTION_END();
regards
sr114
 
Status
Not open for further replies.

Similar threads