HELP PLEASE FOR CREATING ATR related AFL

midhoo

Well-Known Member
#1
Can anyone help to correct the follwing AFL code for plot daily ATR into 5m chart.
I want Daily ATR plotted as per intraday High and Low. I am using 5m chart.




TimeFrameSet( inDaily ); // switch now to daily

function CDL( array )
{
doy = DayOfYear();
Lastdoy = doy == LastValue( doy );
Dayline = array * Lastdoy;

return IIf( Dayline, Dayline, Null );
}

dATR = ATR(14);
AvgAtr = (dATR/2);

H1 = TimeFrameGetPrice( "H", inDaily);
L1 = TimeFrameGetPrice( "L", inDaily);
Mid = (H1+L1)/2;

TopL = (Mid+AvgAtr);
BotL = (Mid-AvgAtr);

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );


Plot( TimeFrameExpand( TopL, inDaily, expandLast), "", colorYellow, styleLine + styleDashed + styleNoRescale );
Plot( TimeFrameExpand( BotL, inDaily,expandLast), "", colorYellow, styleLine + styleDashed + styleNoRescale );

_SECTION_END();
 

rvlv

Active Member
#2
please try this
------------------------------------------------------
TimeFrameSet (inDaily);
dATR20=ATR(20);

TimeFrameRestore();

Plot( TimeFrameExpand( datr20, indaily), " datr20 from daily bars", colorRed );
 

Similar threads