Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problen with a secondary dataseries

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

    Problen with a secondary dataseries

    Hello
    I have the following problem
    I am building a strategy based on 1 minute Japanese candlesticks.
    And additionally I have added a 30 second data series.
    The following is happening to me: Apparently when I ask what bar is closing, in some cases it returns that at the minute closing "BarsInProgress" always returns 1 and I cannot process the closing of the 1 minute bar and it breaks the logic of the strategy.
    As you will see, the cycle goes through OnBarUpdate() twice with BarsInProgress = 1, which is not good for me.
    What could be happening?

    OnBarUpdate() code

    Code:
            protected override void OnBarUpdate()
            {
                string nameprocess = "OnbarUpdate()";
                
                if (CurrentBars[0] < BarsRequiredToTrade) return;
                if (CurrentBar < BarsRequiredToTrade) return;
                if (!this.EnabledTotrade) return;
    
                myDate = (this.Time[0].Year * 10000) + (this.Time[0].Month * 100) + this.Time[0].Day
                
                if (this.CurrentBars[0] == pBarToDebug || (this.Time[0].ToShortTimeString() == this.pTimeToDebug))
                {
                    Draw.ArrowLine(this, string.Format("Line-{0}",totLines++), 0, this.High[0] + 20, 0, this.High[0] + 15, Brushes.Aquamarine, DashStyleHelper.Solid, 5);
                    myPrint(string.Format("{0,30} - 000 - Bar = {1,6} - Time= {3} {2} - this.EnabledTotrade= {4,5} - BarsInProgress = {5,6}",
                        nameprocess, this.CurrentBars[0], this.Time[0].ToShortTimeString(), this.myDate, this.EnabledTotrade, BarsInProgress ));
                }            
                /// -----------------------------------------------------------------------------------------------------
                /// CUIDADO
                
                if ( (BarsInProgress != 0) && pCheckVolatility)
                {
                    EnabledTotradeVol    = true;
                    for (int bar = 0; bar < 11; bar++)
                    {
                        if ((this.VolumeUpDown(BarsArray[1])[bar] > pVolUpDownMinimo) ||
                            (this.ATR(BarsArray[1], pATRperiod)[bar] > pATRlimitInf))
                            EnabledTotradeVol    = false;
                    }
                    //return;
                }
                if (!this.EnabledTotradeVol) return;
                if (BarsInProgress != 0) return;
    Output
    MB_CandleEMA1 --> ---------------------------------------------------------------------------------------------------------------------------
    MB_CandleEMA1 --> OnbarUpdate() - 000 - Bar = 180 - Time= 20250210 12:09 - this.EnabledTotrade= True - BarsInProgress = 1
    MB_CandleEMA1 --> OnbarUpdate() - 000 - Bar = 180 - Time= 20250210 12:09 - this.EnabledTotrade= True - BarsInProgress = 1
    MB_CandleEMA1 --> ---------------------------------------------------------------------------------------------------------------------------

    #2
    Hello mbcito,

    The print you have uses a time condition so that may only match one of the series you are using. To see how the bars are actually processing you can print outside of that condition for every bar and see what the timestamps on that series are. Time[0] represents the time of the series calling OnBarUpdate.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse, the coding and operation are correct, I did the incorrect analysis (error analyzing the variable this.EnabledTotradeVol).

      Thank you for opening my eyes and your analysis.

      Greetings
      Mariano

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pjsmith, 10-01-2019, 08:59 AM
      26 responses
      1,988 views
      0 likes
      Last Post nephew94  
      Started by Str8boominit, 04-14-2025, 06:03 PM
      6 responses
      72 views
      0 likes
      Last Post Str8boominit  
      Started by TAJTrades, Today, 09:01 AM
      5 responses
      29 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by quantyse_ntforum, 03-10-2025, 09:05 AM
      14 responses
      244 views
      0 likes
      Last Post dakensei  
      Started by ntwong, 10-08-2024, 08:22 PM
      10 responses
      228 views
      0 likes
      Last Post akvevo
      by akvevo
       
      Working...
      X