how to code first 15 min bar of the day?

#1
Hi there,

I need buy at close at first 15 min bar of the day and sell with fix take profit at next 15 min bars.

How to code this 'close price of the first 15 min bar'?
 

casoni

Well-Known Member
#2
Hi there,

I need buy at close at first 15 min bar of the day and sell with fix take profit at next 15 min bars.

How to code this 'close price of the first 15 min bar'?
Hello,
there is an easy way to do , as you said you want to buy at close of 1st 15min bar ..... easy way is , use 15min timeframe chart ......

or expalin the concept properly
Thank you
 
#3
sorry, for black bar (if O<C) I have

Buy = C[0];
Sell = C[0]+200;

ami buys at every single bar, but I need one trade in a day,
buy at close of 1st bar and sell at buyprice+x
 

boarders

Well-Known Member
#4
example if your market starts at 0915 am then put 092959 other wise replace by adding 14 minutes 59 seconds to the market open time.

buy=now(4)==092959;
sell=valuewhen(timenum()==091500,C) + 200;

in tools preferences - intraday select start of time interval.
 

boarders

Well-Known Member
#6
buy=TIMENUM()==093000;
sell=valuewhen(timenum()==093000,O) + 200;

THE buy=now(4)==092959; will work only when the time is exactly 092959 and cannot be plotted on afl. the other solution is to use the above code which means that the buy will happen at the open of the second candle of 15 minutes chart after the first candle closes. the rates will not be much different but this can be plotted