Hello Friends !!
I have been stuck on a code for last few days and could not find a solution.
I wish to generate signal at my desired buy and sell condition but this AFL generates on the open of the current candle.
i = BarsSince( Day() );
StartBar = ValueWhen(TimeNum() == 091500, BarIndex());
buystop=(Ref(o,i))*.9996;
SellStop=(Ref(o,i))*1.0004;
BuyPrice=Max(buystop,L);
SellPrice=Min(SellStop,H);
ShortPrice=SellPrice ;
CoverPrice=BuyPrice ;
tn = TimeNum();
startTime = 092000; // start in HHMMSS format
endTime = 151000; // end in HHMMSS format
StopTime=151500;
timeOK = tn >= startTime AND tn <= endtime;
BuySignal=((Buy1 OR Buy2)AND Buyprice) AND timeOK;
SellSignal=((Sell1 OR Sell2) AND SellPrice) OR Cross(tn,EndTime);
ShortSignal=((Sell1 OR Sell2) AND ShortPrice) AND timeOK;
CoverSignal=((Buy1 or buy2 ) AND CoverPrice) OR Cross(tn,EndTime);
Buy=Ref(BuySignal,0);
Sell=Ref(SellSignal,0);
Short=Ref(ShortSignal,0);
Cover=Ref(CoverSignal,0);
ApplyStop( stopTypeLoss, stopModePercent, .50 );