Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add()... causing cs 1502 & 1503 - NT7

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

    Add()... causing cs 1502 & 1503 - NT7

    Hi,
    I'm trying to add a longer term MACD to my indicator. Below code is copied from NT7 strategy sample, but still causing errors:

    protected override void Initialize()
    {
    // Add 10 minute Bars object to the strategy
    Add(PeriodType.Minute, 10);
    Add(MACD(5,20,30)); // This line causing errors
    //Add(SMA(50)); -- orig NT code also causing errors if uncomment --

    CalculateOnBarClose = true;
    }

    If I remove Add MACD and uncomment the original NT code: Add(SMA(50)); this will cause the same errors. The strategy sample compiles w/out errors.

    I just noticed another problem: the Add(PeriodType.Minute, 10); causing all my arrows up/down dissapearing from the chart. If I comment this line - all works fine.
    Thank you.
    Regards, Art.
    Last edited by Art09; 01-31-2011, 09:42 AM.

    #2
    Hi Art,

    Yes, you can add Indicators to strategies for visualization but you can't use this approach in an indicator.

    You can call the MACD indicator in your custom indicator if you want to calculate a value on it. If you want to visualize it, then you need to set plots in your indicator. Your options for setting plots are:
    • Duplicating the MACD logic in your new indicator.
    • Set plots based on called MACD value.
    • Creating a copy of MACD indicator (Right Click Save as from MACD editor) and working from that.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      How would I calc. values or get a direction-rising/falling of higher time frame MACD in my custom indicator? If higher time frame MACD is rising then return 1... and pass this value to my custom indicator... I'd like to be able to read values of higher time frame MACD from the indicator attached to my lower time frame chart. Is this possible at all? How would I do this? Is there lk global variable or such? Is there a sample or help on this topic please?
      Thank you very much.
      Last edited by Art09; 02-02-2011, 08:09 PM.

      Comment


        #4
        Yes, there's a sample multiTimeFrame indicator built into the platform. You can access by clicking Tools > Edit NinjaScript > Strategy > SampleMultiTimeFrame.

        It's easy to access plots from other indicators. You just call the indicator and then the plot.
        EX:
        MACD(12,26,3).Avg[0]

        If you want to access indicator values that are not plots, this sample can help:
        Last edited by NinjaTrader_RyanM1; 02-03-2011, 09:26 AM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thank you. But that example is for the strategy that uses Add()... which did not work... The question is how can I check the higher time frame MACD value from the lower time frame indicator. For ex. call this inside the indicator on 5 min chart:
          double 15minChartMacdVal = MACD(12,26,30).Avg[0]; // This should return the value of 15 min. chart MACD...
          Thank you very much.

          Comment


            #6
            You need to work with multiple series scripts and Add() is used for this to add a secondary time frame, not indicator plots. The sample is relevant to what you're looking to do.

            Documentation for multiple series scripts is available here:


            Please review the sample and documentation for help working with multi time frame scripts. If you're having trouble implementing it, please share what you have written so far.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            597 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            555 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X