Hi,
My requirement is to plot a simple horizontal THIN line(less distracting) for previous day's MCX morning sessions High lows and evening sessions high lows and current days morning sessions high lows when evening session starts.
I have started with the AFL, but 4hr doesn't display the levels correctly. May be some AFL expert can help fix this.
Thanks.
My requirement is to plot a simple horizontal THIN line(less distracting) for previous day's MCX morning sessions High lows and evening sessions high lows and current days morning sessions high lows when evening session starts.
I have started with the AFL, but 4hr doesn't display the levels correctly. May be some AFL expert can help fix this.
Thanks.
Code:
/* Indicator will plot Previous day Session highs and lows and current day session morning session.
MCX Morning session - 10 a.m to 5 p.m
MCX Evening session - 5 p.m to 11.30/11.55 p.m
For current day we plot only morning session , as this helps to trade during evening sessions.
BUGS :
12/6/2014 : Issue with 4h TF - Session hi/lo don't show correctly. 1H and 2H Timeframe shows hi/lo correctly.
TODO:
- Plot Previous day Morning & Evening Session Hi/lo.
*/
function plotSessionHiLo( MorningSession, EveningSession , color )
{
PlotGrid(MorningSession, colorYellow);
PlotGrid(EveningSession, colorYellow);
}
//get todays morning session
isCurrentDay = 0;
isPreviousDay = 0;
isTodayMorningSession = 0;
isTodayEveningSession = 0;
isCurrentDay = IIf( DateNum() == LastValue(DateNum(),1) ,1,0); //check if current day
isPreviousDay = IIf( DateNum()-1 == LastValue(DateNum()-1,1) ,1,0);; // check for previous day
printf("\n Current day = %f",isCurrentDay);
printf("\n isPreviousDay day = %f",isPreviousDay);
MorningSessionTR = TimeNum() >= 100000 AND TimeNum() <= 170000; // Morning Session
EveningSessionTR = TimeNum() >= 170000 AND TimeNum() <= 235900; // Evening Session
isTodayMorningSession = IIf(isCurrentDay AND MorningSessionTR AND NOT EveningSessionTR ,1,0);
isTodayEveningSession = IIf(isCurrentDay AND NOT MorningSessionTR AND EveningSessionTR ,1,0);
printf("\n isTodayMorningSession = %f",isTodayMorningSession);
printf("\n isTodayEveningSession = %f",isTodayEveningSession);
//Get Current day morning Session H/L
aCurrentDayMorningHighs = IIf(isTodayMorningSession , H, Null);
aCurrentDayMorningLows = IIf(isTodayMorningSession , L, 1000000);
// if evening session , then plot the current day morning session H/L
if (LastValue(isTodayEveningSession,1))
{
printf("\n Plotting MorningSession H/L...");
morningSessionHi = LastValue( Highest( TimeFrameExpand(aCurrentDayMorningHighs,inHourly,expandfirst)) , 1 );
morningSessionLo = LastValue( Lowest(aCurrentDayMorningLows) , 1 );
printf("\n Morning Hi = %f",morningSessionHi);
printf("\n Morning Lo = %f",morningSessionLo);
plotSessionHiLo(morningSessionHi,morningSessionLo,colorYellow);
}
// Get Previous day Morning & Evening Session H/L
// how to get previous day morning high lows and evening high lows?
Last edited: