It’s really unclear to me how to refer to different points in time in a single Seetu script. I want to add a simple max hold duration as a sell trigger (in this case 14 days). Everything else in this script is working, but positions are often being held beyond 14 days:
// Just starting with the example Rsi script:
Rsi_Value = CalcRSI();
BuyDate = Day();
SellDate = DateTimeAdd(BuyDate, 14, inDaily);
// Buy if RSI_Value crosses above 30
Buy = Cross(Rsi_Value, 30);
// Sell if RSI_Value falls under 70 ***or in 14 days***:
Sell = Cross(70, Rsi_Value) OR Day() >= SellDate;
// ... some out-of-scope logic here, then... //
C2TradingSignal(sigBTO, priceType = priceLimit, stopLoss = BuyPrice * 0.9, profitTarget = BuyPrice * 1.1);
// ...but lawdy, some of my positions are still being held a looonnnnng time!
I’ll bet this is because Day() returns the same value both times it’s called, so Day() >= SellDate
is never true. However, it’s not obvious at all to me how to evaluate how long the position has been held when determining whether to sell.
Any ideas?
Thanks!