Please suggest the tradescript code for the following strategy

Buy if the price is over previous day’s high

Sell if the price is lower than previous day’s low

I used the following:



and applied it to the day charts. But I’d want to use them for 5 min or 15 minute charts. When I apply the code to the 5 min chart, it doesn’t give me correct results that I should be expecting. Please advise.

the above code is correct and it has to be used with the day candles as your condition is based on previous day,

if you are using with 15 minute time frame it will check previous 15 minute candle.

I want an alert to enter the market as soon as the market crosses yesterday’s high. So, I want to apply the EA to a 5 min or a 15 min timeframe. But I want yesterday’s high/ low to work on day’s timeframe. How do I acheive that?

as tradescript is based on OHLC values and time frame it is not possible to check day condition on minute time frame

use 8 hour candle…only one candle will be there for 1 day…so ref(high, -1 ) can be used