Goal - To have a stop and target order created at order entry based on a multiple of the ATR of the trigger bar
Code snippets of where I am now -
private Series<double> ATR2;
...
ATR1 = ATR(Close, 14);
ATR2[0] = Convert.ToDouble(ATR1);
SetStopLoss(@"PPOShort", CalculationMode.Price, (Convert.ToDouble(Close) + (ATR2[0] * 2)), true);
SetProfitTarget(@"PPOShort", CalculationMode.Price, (Convert.ToDouble(Close) + (ATR2[0] * 3)));
This compiles, but will not enter any orders. This appears in the Output window:
"Error on calling 'OnStateChange' method: Unable to cast object of type 'NinjaTrader.NinjaScript.Indicators.ATR' to type 'System.IConvertible'."
Is what I am trying to accomplish even possible in Ninjascript? I am coming from Pine script on Tradingview and it is so simple to perform calculations on indicator values there that I got spoiled.
Any help/direction would be appreciated!
Mickey

Comment