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 reekotubbs, Today, 01:09 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by DJ888, Yesterday, 05:57 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by lucyb, Yesterday, 04:09 PM
      3 responses
      19 views
      0 likes
      Last Post lucyb
      by lucyb
       
      Started by DayTradingDEMON, Yesterday, 08:54 AM
      12 responses
      36 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by aligator, 06-05-2018, 01:25 AM
      60 responses
      5,920 views
      10 likes
      Last Post aligator  
      Working...
      X