NT8 documentation states that the NT7 UserDefinedMethods concept has been moved to the AddOns and the following provided as a template.
[COLOR=#0000ff]namespace[/COLOR]NinjaTrader.NinjaScript.Indicators { [COLOR=#0000ff]public[/COLOR]partial[COLOR=#0000ff]class[/COLOR]MyMethods:Indicator { [COLOR=#008000]//Sample method which calculates the delta of two prices[/COLOR] [COLOR=#0000ff]public[/COLOR][COLOR=#0000ff]static[/COLOR][COLOR=#0000ff]double[/COLOR]calculateDelta([COLOR=#0000ff]double[/COLOR]firstPrice,[COLOR=#0000ff]double[/COLOR]secondPrice) { [COLOR=#0000ff]return[/COLOR]Math.Abs(firstPrice-secondPrice); } [COLOR=#008000]//Sample method which prints Position information[/COLOR] [COLOR=#0000ff]public[/COLOR][COLOR=#0000ff]static[/COLOR][COLOR=#0000ff]void[/COLOR]printPositionInfo(Positionposition) { Print(String.Format([COLOR=#800000]"{0}: {1} {2} at {3}"[/COLOR],position.Instrument,position.Quantity,position.MarketPosition,position.AveragePrice)); }
I have added the required "using" statement in my Indicators to enable calling of the methods but I am not able to use the Print Method as above. I am getting an error on compile stating "An object reference is required for the non-static ... method .. NinjaTrader.NinjaScript.NinjaScript.Print(object)" .
What do I need to modify to be able to use the Print method from within classes that inherit from AddOnBase?
Thanks,
Comment