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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    47 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    15 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    21 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X