Hi. Is there a code to sell if the current price, within a day candle, is less than the open.
Have tried several codes but nothing works.
Thanks in advance.
Strategies are only executed when a candle closes.
On a Daily TF any strategy cannot be executed while the daily candle is being formed.
But you can take advantage of the MTF, Multiple Time Frame, support. You can use the search box to know more about it.
This example shows how to do what you want:
Timeframe(Daily,UpdateOnClose)
OpenD = open
Timeframe(default)
If close < OpenD Then
SELL AT Market
EXITSHORT AT Market
Endif
the default TF is the one that sets the pace and must be the one on your chart. It must be the lowest TF used and all higher TF’s used must be a multiple of it.
I suggest that you use a 5-minute or 1-minute TF to launch your strategy, so that your strategy is executed every 5 minutes or every minute to check price while the Daily candle is not yet closed.
Sorry for the delay getting back to you Robertoguzzi.
As I am still learning I will take your reply on board.
Thank you