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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    557 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X