Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

use the output of indicator as the parameter of another one

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

    use the output of indicator as the parameter of another one

    I have one question about how to use the output of one indicator as the input parameter of another indicator.

    I have two data series. series 1 is 1 minute data, series 2 is daily data. I want to use the daily 60 days move average close price to do some simple math as one input parameter of another indicator.

    Here are the codes

    A1 = 25;
    A2 = 70;
    A3 = 5;
    A4 = 10;
    A5 = 10;
    A6 = 5;
    A7 = 10;
    A8 = 10;

    Quantity = 1;

    }
    else if (State == State.Configure)
    {
    AddDataSeries("YMMAR25",Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    Moonlight1 = Moonlight(Close, A1, 70*(SMA[0]/42000), Convert.ToInt32(A3), Convert.ToInt32(A4), true, Convert.ToInt32(A5));
    SMA1=SMA(Closes[1],60);


    I got the errors as follows
    NinjaScript File,Error,Code,Line,Column,
    Moonligh.cs,Cannot apply indexing with [] to an expression of type 'method group',CS0021,331,72,

    Is there any walk around method? Thank you.

    #2
    Hello Playdc,

    Thank you for your post.

    You would first need to define the SMA, right now you're directly applying an index to the SMA method (in the line that is defining the Moonlight indicator) which is leading to the compile error.

    For example,

    Code:
    //at the class level
    private SMA SMA1;
    
    //in State.DataLoaded
    SMA1 = SMA(14);
    Then you could call SMA1[0] when the script begins processing data, which would be when State is State.Historical or State.Realtime from OnBarUpdate(). Note that you would not be able to call SMA1[0] in State.DataLoaded, because the script hasn't begun processing any data to call any value of the SMA. You will likely hit a runtime error if you attempt to do this.

    Code:
    //in OnBarUpdate
    myIndicator = (SMA1[0]);
    Please let us know if you have any further questions.
    Last edited by NinjaTrader_Gaby; 01-17-2025, 08:02 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X