Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 indicators in strategy, only 1 plots...

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

    2 indicators in strategy, only 1 plots...

    The indicators are identical except for name, I have checked the vars via Print() and all looks good, however MACDrossSlow does not plot.

    Here is the strategy script:
    Code:
     
       if (CurrentBar == 0)
       {
        MACDCrossFast().fastEma.Set(Input[0]);
        MACDCrossFast().slowEma.Set(Input[0]);
        MACDCrossFast().Value.Set(0);
        MACDCrossFast().Avg.Set(0);
        MACDCrossFast().Diff.Set(0);
        MACDCrossSlow().fastEma.Set(Input[0]);
        MACDCrossSlow().slowEma.Set(Input[0]);
        MACDCrossSlow().Value.Set(0);
        MACDCrossSlow().Avg.Set(0);
        MACDCrossSlow().Diff.Set(0);
       }
       else
       {
        if(BarsInProgress == fastseries)
        {
         MACDCrossFast().fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * MACDCrossFast().fastEma[1]);
         MACDCrossFast().slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * MACDCrossFast().slowEma[1]);
     
         macd = MACDCrossFast().fastEma[0] - MACDCrossFast().slowEma[0];
         macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * MACDCrossFast().Avg[1];
     
         MACDCrossFast().Value.Set(macd);
         MACDCrossFast().Avg.Set(macdAvg);
         MACDCrossFast().Diff.Set(macd - macdAvg);
        }
        if(BarsInProgress == slowseries)
        {
         MACDCrossSlow().fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * MACDCrossSlow().fastEma[1]);
         MACDCrossSlow().slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * MACDCrossSlow().slowEma[1]);
     
         macd = MACDCrossSlow().fastEma[0] - MACDCrossSlow().slowEma[0];
         macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * MACDCrossSlow().Avg[1];
     
         MACDCrossSlow().Value.Set(macd);
         MACDCrossSlow().Avg.Set(macdAvg);
         MACDCrossSlow().Diff.Set(macd - macdAvg);
        }
       }
    Here is an indicator script:

    Code:
     
      protected override void Initialize()
      {
       Add(new Plot(Color.Green, PlotStyle.Dot, "Macd"));
       Add(new Plot(Color.Black, "Avg"));
       Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));
       Add(new Line(Color.DarkGray, 0, "ZeroLine"));
       fastEma = new DataSeries(this);
       slowEma = new DataSeries(this);
      }
    There is no code for OnBarUpdate() in indicators.
    Both plot if I use the default series for both.
    Hmm... Neither plot using series 1, but the Print() reprsents the values properly...
    here is the script that creates the series:

    Code:
       PeriodType ID = BarsPeriod.Id;
       int VAL = BarsPeriod.Value;
       Print(ID+", "+VAL);
       Add(ID,VAL*2);//Scale 1
       Add(ID,VAL*4);//Scale 2
       Add(ID,VAL*8);//Scale 3
       Add(ID,VAL*16);//Scale 4
       Add(ID,VAL*32);//Scale 5
       Add(ID,VAL*64);//Scale 6
       Add(ID,VAL*128);//Scale 7
       Add(ID,VAL*256);//Scale 8
       Add(ID,VAL*512);//Scale 9
       Add(ID,VAL*1024);//Scale 10
       Add(ID,VAL*4096);//Scale 11
    Last edited by dhunnewell; 03-10-2010, 09:07 AM.

    #2
    dhunnewell, is this for NT 65 or NT 7 beta?

    Do you see any log errors as this occurs?

    Thanks

    Comment


      #3
      6.5 No errors, I hve a feeling it is a scope prob, my values are calculated properly from the correct data series... but if that series is not 0 then no plot.

      Comment


        #4
        Any way you could send me the full export to test on my end? NT 6.5 would not allow for MultiSeries plotting per default.

        One thing I spot that's not supported codewise, is dynamically adding the bars periods as well as accessing the BarsPeriod in the Initialize() of the code.

        Comment


          #5
          Yeah, all that occurred to me, however I can print the data for the plots and it is correct, IE: The values for 'macd' and 'macdAvg' are correct. How would you like me to send export? Also the dynamic creation of the series is working fine! Perhaps a trick you can pass on?
          Last edited by dhunnewell; 03-10-2010, 09:58 AM.

          Comment


            #6
            You can send the exported script to support at ninjatrader dot com Attn Bertrand, I'll then take a look.

            Yes, the dynamic adding of bars objects might work as you have found, but it's still unfortunately not supported.

            Comment


              #7
              I cannot find an email and cannot attach the file via support request.
              Oh OK, the 'at' went down the wrog pipe.
              Last edited by dhunnewell; 03-10-2010, 10:27 AM.

              Comment


                #8
                Thanks, got the file, will take a look shortly.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                627 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                359 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                562 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                567 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X