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

The Constant High[0] changes during the loop

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

    The Constant High[0] changes during the loop

    Hello
    have a nice day
    The length of the last candle is 10.
    It is stored in a variable called BarLength.
    The BarLength should be constant in the loop, but it changes as you can see in the photo.

    PHP Code:
            protected override void OnBarUpdate()
            {
                //Add your custom indicator logic here.
                if (Bars==null) return;
                
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = 
                Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
                
                if (barsType == null) return;
                
                int BarLength=(int) ((High[0] - Low[0]) / TickSize);
                
    
                for (int i = 0; i <=BarLength; i++) 
                {
                  Draw.Text(this,"myTaga-"+i.ToString(),High[0].ToString(),i,High[i],Brushes.Yellow);
                  Draw.Text(this,"myTagb-"+i.ToString(),BarLength.ToString(),i,Low[i],Brushes.Yellow);
                }
            } 
    
    Click image for larger version

Name:	GC 08-24 (1 Min Volumetric) 2024_06_14 (3_58_22 PM).png
Views:	17
Size:	131.3 KB
ID:	1307323

    #2
    I wrote the programming code in a different way, but the problem is still there, I think there is something wrong with my code.
    Because I feel instead of the last candle, Indicator reviewed daily​ High and Low

    PHP Code:
            protected override void OnBarUpdate()
            {
                if (Bars==null) return;
                if (CurrentBar<100) return;
                
                
                Draw.Text(this,"myTag-01",BarsArray[0].GetTime(CurrentBar).ToString(),1,BarsArray[0].GetHigh(CurrentBar),Brushes.Red);
    
                for (double Price = BarsArray[0].GetHigh(CurrentBar); Price >=BarsArray[0].GetLow(CurrentBar); Price-=TickSize) 
                {
                  Draw.Text(this,"myTaga-"+Price.ToString(),Price.ToString(),0,Price,Brushes.Yellow);
                }
            } 
    
    Click image for larger version

Name:	GC 08-24 (1 Min Volumetric) 2024_06_14 (6_33_06 PM).png
Views:	10
Size:	157.9 KB
ID:	1307332
    Attached Files

    Comment


      #3
      Hello MokhtarVerdi,

      Use prints to understand the behavior.

      Below is a link to a support article on using prints to understand behavior.


      Print the time of the bar, print BarsArray[0].GetHigh(CurrentBar)​ and BarsArray[0].GetLow(CurrentBar) one line above the for loop.
      Print Price within the logic block of the for loop.
      Include labels for each value.

      Save the output to a text file (right-click the output window > Save as) and include this with your reply.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NeoTraderBot, Today, 10:55 PM
      0 responses
      5 views
      0 likes
      Last Post NeoTraderBot  
      Started by OliverWaters, Today, 10:35 PM
      0 responses
      6 views
      0 likes
      Last Post OliverWaters  
      Started by Graci117, 07-06-2024, 09:32 AM
      6 responses
      37 views
      0 likes
      Last Post Graci117  
      Started by AdamDJ8, 07-01-2024, 06:50 PM
      2 responses
      120 views
      0 likes
      Last Post AdamDJ8
      by AdamDJ8
       
      Started by AdamDJ8, 07-01-2024, 05:55 PM
      3 responses
      32 views
      0 likes
      Last Post AdamDJ8
      by AdamDJ8
       
      Working...
      X