Hi all,
I want to calculate the range (High –Close) of AM (9:30-13:00) and want to plot the result at the last bar of AM in 5-min chart, and then want to calculate the range (High –Close) of PM (13:01-16:00) and want to plot the result at the last bar of AM in 5-min chart.
I tried to code it:
tn1 = TimeNum();
startTime = 93000;
endTime = 130000;
timeOK1 = tn1 >= startTime AND tn1 <= endTime;
HHV1 = (C, tn1);
LLV1 = (C, tn1);
Range1 = HHV1 - LLV1;
Range1bar = lastvalue (timeOK1, True);
tn2 = TimeNum();
startTime = 130100;
endTime = 160000;
timeOK2 = tn2 >= startTime AND tn2 <= endTime;
HHV2 = (C, tn2);
LLV2 = (C, tn2);
Range2 = HHV2 - LLV2;
Range2bar = lastvalue (timeOK2, True);
dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Range1bar [i] ) PlotText( "Range1@" + C[ i ], i, Range1bar[ i ]+dist[i], colorGreen );
}
dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Range2bar [i] ) PlotText( "Range2@" + C[ i ], i, Range2bar[ i ]+dist[i], colorGreen );
}
However, it didn’t work, anyone know to how to code it? Please tell me, thank you.