Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

MTF SMA plot issue

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

    MTF SMA plot issue

    Hello dear friends, i have a sma mtf indicator calculation is right but when i plot it, it shifts.
    Here is the code
    Code:
    else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Minute, TimeFrame);
                }
                else if (State == State.DataLoaded)
                {
                    // Syncs a DataSeries object to the primary bar object
                    primarySeries = new Series<double>(this);
    
                    /* Syncs another DataSeries object to the secondary bar object.
                    We use an arbitrary indicator overloaded with an ISeries<double> input to achieve the sync.
                    The indicator can be any indicator. The Series<double> will be synced to whatever the
                    BarsArray[] is provided.*/
                    secondarySeries = new Series<double>(SMA(BarsArray[1], SMAPeriod));
                }
            }
    
            protected override void OnBarUpdate()
            {
                  foreach(int CurrentBarForSeries in CurrentBars)
                  {
                    if (CurrentBarForSeries < 1)
                    {
                      return;
                    }
                  }
    
                Value[0]=SMA(Medians[1], SMAPeriod)[0];
    
            }
    What i am doing wrong?

    Thank you!
    Click image for larger version

Name:	exz.png
Views:	127
Size:	10.2 KB
ID:	1061388
    Attached Files

    #2
    Hello stoxos,

    Thanks for your post.

    Plots are synchronized to the primary data series. If your added plot is plotting data from a higher time frame than the primary data series, we will not have a more recent value for the plot until the that secondary bar closes and updates the value being plotted.

    If you use Calculate.OnPriceChange then each data series will update with incoming price changes and plot values will be calculated for the developing bars without having to wait for the secondary bar to close to update that plot. Please note that historical data will still process OnBarClose, so you could also move forward by having the primary data series as the higher time frame and the secondary series as the smaller time frame.

    Please let us know if you have any additional questions.​​
    JimNinjaTrader Customer Service

    Comment


      #3
      Yes you are right i tried OnPriceChange, but nothing changed. So i will pass that project. But thank you.
      P.S. To anyone else, this is not an issue on NT platform, apparently other platforms are also having hard time with multitimeframe data series.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      2 views
      0 likes
      Last Post DanielTynera  
      Started by yertle, 04-18-2024, 08:38 AM
      9 responses
      40 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by techgetgame, Yesterday, 11:42 PM
      0 responses
      9 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Yesterday, 11:36 PM
      0 responses
      2 views
      0 likes
      Last Post sephichapdson  
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,615 views
      0 likes
      Last Post aligator  
      Working...
      X