Reputation: 23
I want to write an script in pine in which my short entry condition is related to my previous long entry price, how can I do it? for example short entry when price hits (1.1*previous long entry price) so far I found out I can refer to previous candles price by "close[]" but couldn't find a way to refer to previous long entry price.
In the example below I don't know what to put instead of ? as a reference to previous long condition price.
longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
strategy.entry("buy", strategy.long)
shortCondition = close >= 1.1 * ?
if (shortCondition)
strategy.exit("sell", strategy.short)
Upvotes: 2
Views: 3653
Reputation: 34
strategy.position_avg_price gives you the average price for long and short entries
strategy.long / strategy.short gives you the price for long or short entries
Upvotes: 1