how to mark hrly(or 30min) high lows in 5min TF chart - AFL

#1
Can some one pls help me with this AFL for marking highs and lows of hrly (or any other TF) on a 5 min TF chart?

sample image is given

hope some one with good heart help me out

thanks

 
#2
Can some one pls help me with this AFL for marking highs and lows of hrly (or any other TF) on a 5 min TF chart?

sample image is given

hope some one with good heart help me out

thanks

hi, I used some of my code. I plotted the dashed high and low lines for clarity since it depends where a certain timeframe (e.g. hour) starts and ends. Have a look.


// Amibroker AFL code by Edward Pottasch, 7/21/2011
Version(5.21);
xx=BarIndex();x=xx;Lx=LastValue(x);
tf=Param("Time Frame (min)",60,1,500,1);tfrm=in1Minute*tf;

TimeFrameSet(tfrm);
H_tfrm=H;
L_tfrm=L;
TimeFrameRestore();
Lkbk=tfrm/Interval();
if(Lkbk>1)
{
H_tfrm=TimeFrameExpand(H_tfrm,tfrm,expandFirst);
L_tfrm=TimeFrameExpand(L_tfrm,tfrm,expandFirst);
}

H_mark=H_tfrm==H;
L_mark=L_tfrm==L;

GraphXSpace=5;
SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,ColorRGB(0,75,0),IIf(C<=O,ColorRGB(75,0,0),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ColorRGB(0,255,0),IIf(C<=O,ColorRGB(255,0,0),colorLightGrey)),64,0,0,0,0);
PlotShapes(IIf(L_mark,shapeSmallCircle,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(L_mark,shapeHollowCircle,shapeNone),colorWhite,0,L,-15);
PlotShapes(IIf(H_mark,shapeSmallCircle,shapeNone),colorRed,0,H,15);
PlotShapes(IIf(H_mark,shapeHollowCircle,shapeNone),colorWhite,0,H,15);
Plot(H_tfrm,"",colorRed,styleDashed);
Plot(L_tfrm,"",colorGreen,styleDashed);

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 = Name() + EncodeColor( colorYellow ) + " | " +
EncodeColor( ColorRGB(131,111,255) ) + "Chart Timeframe: " + tt + tf + EncodeColor( colorYellow ) + " | " +
EncodeColor( ColorRGB(131,111,255) ) + "Trend Timeframe: " + tta + tfa + EncodeColor( colorWhite )
+ EncodeColor( colorYellow ) + " | ";
 
#4
can you give us a daily version... please
(i've tried to modify your code unsuccessfully with strange result...expanding time frame to xxxxxxxx minutes)
very thanks
 
#5
can you give us a daily version... please
(i've tried to modify your code unsuccessfully with strange result...expanding time frame to xxxxxxxx minutes)
very thanks
hi, the code works in all timeframes. I just used a small range in the parameters window up to 500 minutes.

try using 50000 instead of 500, like:
tf=Param("Time Frame (min)",60,1,50000,1);tfrm=in1Minute*tf;

then do a rightclick in the parameter window. Do a "reset all"

now you can use a timeframe greater than 1 day. Using 10080 minutes gives you 1 week.
 
#7
hi, the code works in all timeframes. I just used a small range in the parameters window up to 500 minutes.

try using 50000 instead of 500, like:
tf=Param("Time Frame (min)",60,1,50000,1);tfrm=in1Minute*tf;

then do a rightclick in the parameter window. Do a "reset all"

now you can use a timeframe greater than 1 day. Using 10080 minutes gives you 1 week.
i've just modified that line,pheraps my cpu is not very fast so the pc has difficult to display this afl..
anyway i post the modified lines also for lower and daily version:
line 2-//Version(5.21);


thanks anyway
 
Last edited:
#9
many thanks to u

but, how sad...i only have version 5...so it doesnt work for me :mad:

anything can be done? pls :)
maybe try this:

// Amibroker AFL code by Edward Pottasch, 7/21/2011
tf=Param("Time Frame (min)",60,1,50000,1);tfrm=in1Minute*tf;

TimeFrameSet(tfrm);
H_tfrm=H;
L_tfrm=L;
TimeFrameRestore();
Lkbk=tfrm/Interval();
if(Lkbk>1)
{
H_tfrm=TimeFrameExpand(H_tfrm,tfrm,expandFirst);
L_tfrm=TimeFrameExpand(L_tfrm,tfrm,expandFirst);
}
H_mark=H_tfrm==H;
L_mark=L_tfrm==L;

GraphXSpace=5;
SetChartOptions(0,chartShowDates);
Plot(C,"\nPrice",colorWhite,64);
PlotShapes(IIf(L_mark,shapeSmallCircle,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(L_mark,shapeHollowCircle,shapeNone),colorWhite,0,L,-15);
PlotShapes(IIf(H_mark,shapeSmallCircle,shapeNone),colorRed,0,H,15);
PlotShapes(IIf(H_mark,shapeHollowCircle,shapeNone),colorWhite,0,H,15);
Plot(H_tfrm,"",colorRed,styleDashed);
Plot(L_tfrm,"",colorGreen,styleDashed);

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 = Name() + EncodeColor( colorYellow ) + " | " +
EncodeColor( ColorRGB(131,111,255) ) + "Chart Timeframe: " + tt + tf + EncodeColor( colorYellow ) + " | " +
EncodeColor( ColorRGB(131,111,255) ) + "High/Low Timeframe: " + tta + tfa + EncodeColor( colorWhite )
+ EncodeColor( colorYellow ) + " | ";