| namespaceNinjaTrader.NinjaScript.Indicators { publicpartialclassMyMethods // : parent class to inherit from { //Sample method which calculates the delta of two prices publicdoublecalculateDelta(doublefirstPrice,doublesecondPrice) { returnMath.Abs(firstPrice-secondPrice); } //Sample method which prints Position information publicvoidprintPositionInfo(Positionposition) { Print(String.Format("{0}: {1} {2} at {3}",position.Instrument,position.Quantity,position.MarketPosition,position.AveragePrice)); } } } |
protectedoverridevoidOnBarUpdate()
{
if(CurrentBar<1)return;
// Use the static calculateDelta method to calculate the difference between the close of each bar
doubledelta=MyMethods.calculateDelta(Close[0],Close[1]);
Print(delta);
}
When I tried this code out I had to add "static" modifier to the calculateDelta method in the MyMethods class.
Is that correct? If so, then can you fix the typo in the help guide.
Otherwise, what do I need to do to make this work without the "static" modifier.

Comment