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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    133 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    75 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    117 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    113 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    90 views
    0 likes
    Last Post CarlTrading  
    Working...
    X