How to take entry at specific time after signal?

#1
Hello everyone,
I am trying to set trade delay for the next candle after getting buy/sell signal on a specific time.
On a daily timeframe, when I get the buy/sell signal after close crossing the HL averages I want to take position at the NEXT DAY candle at 9:25 AM and backtest accordingly. I tried to do it with Timenum() but I wasn't able to plot it properly to get my results. Can anyone tell me how do I take position on exactly 9:25 am i.e second 10 minutes' candle's opening price?
the market starts at 9:15 and ends at 3:30 btw.
Thanks in advance.
Here's my code-(Keep in mind that I have tried many ways to do this but have failed in everything, so I have kept all the preciously used functions and their parameters in comments. Kindly ignore them. )

/*
1.Plot Chart
2.Plot Ema on Highs and Lows
3.Plot buy/sell signals
4. Entry on specific time.
5.Apply Stoploss
6. Add Transaction cost
7. Set Trade Delay
*/
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Y-Axis Price Color", colorDefault), styleThick | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("EMAs");

Hema = EMA(H, 10);
Lema = EMA(L, 10);

Plot(Hema,"Hema",colorOrange,styleLine);
Plot(Lema,"Lema",colorYellow,styleLine);
ConditionB = C > Hema;
ConditionS = C < Lema;

tn = TimeNum();
NextDay = Ref(Day(),1);
starttime = tn == 091500;
endtime = tn == 033000;
pricetime = tn == 093500;


tmp = TimeFrameGetPrice("open",2*in5Minute);
plotting = TimeFrameExpand(tmp,2*in5Minute);
Plot (plotting,"openingp",colorAqua,styleLine);



Buy = ConditionB;
Sell = ConditionS;
Short = ConditionS;
Cover = ConditionB;



SetTradeDelays(1,1,1,1);
BuyPrice = TimeFrameGetPrice("Open",2*in5Minute,1);
SellPrice = tmp;
ShortPrice = tmp;
CoverPrice = TimeFrameGetPrice("Open",2*in5Minute,1);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);






/*
Kvhod = 130000;
ItsTime = Kvhod == TimeNum();
PriceAtTime = ValueWhen(ItsTime, Open);

/*Entry = 092500;
EntryTime = Entry == TimeNum();
//PriceAtTime = ValueWhen(EntryTime, Open);
//DayChange = Day() != Ref(Day(), 1);

TimeFrameSet(inDaily);
ConditionB = C > Hema;
ConditionS = C < Lema;
TimeFrameRestore();



/*
TimeFrameSet(2*in5Minute);
nextB = BarsSince(conditionB);
nextS = BarsSince(conditionS);
Buy = Ref(nextB,-1);
Cover = Ref(nextB,-1);
Sell = Ref(nextS,-1);
Short = Ref(nextS,-1);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
SetTradeDelays(1,1,1,1);

/*BuyPrice = Open;
ShortPrice = Open;
CoverPrice =Open;
SellPrice = Open;

TimeFrameRestore();




SetTradeDelays(1,1,1,1);
BuyPrice = TimeFrameExpand(EntryPrice,inDaily);
SellPrice = TimeFrameExpand(EntryPrice,inDaily);
ShortPrice = TimeFrameExpand(EntryPrice,inDaily);
CoverPrice = TimeFrameExpand(EntryPrice,inDaily);

*/



PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorWhite, 0,Low, Offset=-20);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone), colorYellow, 0,High, Offset=-20);
PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorWhite, 0,Low, Offset=-20);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone), colorYellow, 0,High, Offset=-20);

_SECTION_END();
 

Broker Special Offers

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?