Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using custom indicator within strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using custom indicator within strategy

    (NT8R12)...

    I'm trying to use a custom indicator from within a strategy I call myTrader.
    I invoke it in the following manner:

    else if (State == State.Configure)
    {
    // myIndie = myCustomIndicator(true, false);
    // AddChartIndicator(myIndie );
    AddChartIndicator(myCustomIndicator(true, false));

    I prefer the commented out approach, because from within the strategy's OnBarUpdate handler I would like to grab the current values of some public (myCustomIndicator) indicator variables using the following format:

    double signalEntryPrice = myIndie.signalEntryPrice;

    instead of having to state it as follows:

    double signalEntryPrice = myCustomIndicator(true, false).signalEntryPrice;

    which seems to be not quite appropriate, since it implies this way will construct another instance of the indicator...

    I am unable to use my preferred approach, because the compiler generates an eror when trying to treat the myCustomIndicator indicator like a class in the following:

    private myCustomIndicator myIndie ;

    'NinjaTrader.NinjaScript.Strategies.Strategy.myCus tomIndicator(bool, bool)' is a 'method' but is used like a 'type'

    What am I doing wrong?

    #2
    Hello CriticalTrader,

    I'm not sure what you are doing wrong as you have not posted the script or code you are using.

    However, attached is a working example that demonstrates using a variable handle to hold an indicator object.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    264 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    168 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    171 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    257 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    209 views
    0 likes
    Last Post CarlTrading  
    Working...
    X