Hi, Ive written some code but i want it to only look at the first 5 min candle of the current day. How can I do this?
Thanks
My code:
//Bear Candle
BearBody = (open - close)
BearWick = (close - low) or (high - open)
BearCandle = BearBody < BearWick
//Bull Candle
BullBody = (close - open)
BullWick = (open - low) or (high - close)
BullCandle = BullBody < BullWick
Screener [BearCandle or BullCandle]
hi, im sorry if im missing something easy but i’m very new to coding with PRT so any help would be hugely appreciated, all i want to know how I can make the above code run on only the first 5 minutes of the current day 🙂
On what timeframe do you want to launch your screener?
on a 5 minute timeframe which ive done, but i only want it to run on the first candle of the day, if i run the code as it is, it just run since earliest date which i dont want.
You can use intradaybarindex to know the actual candlestick number. With it you can restrain your test to the first intradaybarindex.
ive added IntradayBarIndex[0] to the start of my code and it doesn’t work, the candle is the first bar of the day and therefore bar 0 if im not mistaken. If you could give me some help with the syntax when using it in a screener instead of just an indicator that would help me out alot 🙂
Hmmm.. maybe a time condition would meet more the way you are thinking about your screener.
Add a time condition (adapt it to the open time of the instrument of course):
tcondition = time>080000 and time<081000
Your complete code would look like this:
//Bear Candle
BearBody = (open - close)
BearWick = (close - low) or (high - open)
BearCandle = (BearBody < BearWick) and tcondition
//Bull Candle
BullBody = (close - open)
BullWick = (open - low) or (high - close)
BullCandle = (BullBody < BullWick) and tcondition
Screener [BearCandle or BullCandle]
Didn’t test it, Sunday evening coding, should work .. 🙂
thats great thank you very much! i’ll test it tomorrow and update you if it all works 🙂