I am new to PineScript. I need help with a simple strategy that
Buys if the price is higher than the price at the close of the previous day.
Sells if the price is lower than the price at the close of the previous day
How can I do that? Thank you
I am new to PineScript. I need help with a simple strategy that
Buys if the price is higher than the price at the close of the previous day.
Sells if the price is lower than the price at the close of the previous day
How can I do that? Thank you
Go in the pine editor, click on new -> blank strategy script, you will have a good template for strategies, the conditions should be stated in longCondition
and shortCondition
.
longCondition = close > close[1]
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = close < close[1]
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
Note that such strategy is already implemented under the name "Bar UpDn Strategy".