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 aa731, Today, 02:54 AM
      0 responses
      4 views
      0 likes
      Last Post aa731
      by aa731
       
      Started by thanajo, 05-04-2021, 02:11 AM
      3 responses
      470 views
      0 likes
      Last Post tradingnasdaqprueba  
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,237 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      4 views
      0 likes
      Last Post thread
      by thread
       
      Working...
      X