I’ve found a new strategy called the Stiffness Indicator. I’m trying to turn this into a scan but getting rejected at line7:1.Here’s the code and you help.
input price = close;
input length = 60;
input averageLength = 100;
def avg = Average(price, averageLength) – 0.2 * StDev(price, averageLength);
plot Stiffness = Sum(price > avg, length) * averageLength / length;
}
input price = close;
input length = 60;
input averageLength = 100;
input exitLength = 84;
input entryStiffnessLevel = 90.0;
input exitStiffnessLevel = 50.0;
input marketIndex = “SPY”;
def ema = ExpAverage(close(marketIndex), averageLength);
def stiffness = Stiffness(price, averageLength);
def entryPrice = EntryPrice();
def afterEntryCount = if IsNaN(entryPrice[1]) and !IsNaN(entryPrice) then 1 else if !IsNaN(entryPrice) then afterEntryCount[1] + 1 else Double.NaN;
AddOrder(OrderType.BUY_TO_OPEN, stiffness crosses above entryStiffnessLevel and ema >= ema[2], tickcolor = GetColor(6), arrowcolor = GetColor(6), name = “StiffnessLE”);
AddOrder(OrderType.SELL_TO_CLOSE, stiffness crosses below exitStiffnessLevel, tickcolor = GetColor(5), arrowcolor = GetColor(5), name = “StiffnessLX”);
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > exitLength, tickcolor = GetColor(4), arrowcolor = GetColor(4), name = “StiffnessTimeLX”);
Like this:
Like Loading...
Thanks for the advice will try to see if I can work it. The Strategy does work in TOS
No, the code does not work in a strategy at all. I just copy/pasted the code you provided into a new custom strategy and all the same errors are present just like I explained.