Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Real time Calculation

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

    Indicator Real time Calculation

    This indicator is not calculating right when I load it during the section.
    When the previus bar is green the count variable[1] should be = 1
    when I load it if the previus bar is green , then it consider the count variable[1] = 0 and calculate wrong.

    In the chart below you will see it in the last bar

    Can you help me please?


    Click image for larger version

Name:	WROM.png
Views:	373
Size:	46.6 KB
ID:	1099763






    CODE

    IsSuspendedWhileInactive = true;
    AddPlot(new Stroke(Brushes.Black), PlotStyle.Bar,"PlotWeis");

    }
    else if (State == State.DataLoaded)

    Volsum = new Series<double>(this);
    Count = new Series<double>(this);
    VOL1 = VOL(Close);
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    // Bars
    if (Close[0] > Open[0])
    {
    Count[0] = 1;
    }
    else if (Close[0] <= Open[0])
    {
    Count[0] = 0;
    }

    // Count
    if (Count[0] == Count[1])
    {
    Volsum[0] = Volsum[1] + VOL1[0];
    }

    else if (Count [0]!= Count[1])
    {
    Volsum[0] = VOL1[0];
    }

    PlotWeis[0] = Volsum[0];

    // Print(" " +" Data" + Time[0]+ " " +" Count0= " +Count[0] + " ------- " +" Count1= " +Count[1] );

    // Color
    if (Close[0]>Open[0])
    {
    PlotBrushes[0][0] = Brushes.Green;
    }
    if (Close[0]<=Open[0])
    {
    PlotBrushes[0][0] = Brushes.Red;
    }


    }

    #2

    Now I realod the indicator and as you can see it is different. When I realod and the previus bar is red it works ok. Looks like the Count[1] is always = 0 when I load it

    Click image for larger version

Name:	WROM1.png
Views:	364
Size:	46.8 KB
ID:	1099765

    Comment


      #3
      Hello Wagner,

      Thanks for your post.

      Could you clarify on what your expectation is and what you are trying to accomplish?

      Looking at the code, I see that you are tracking if there has been consecutive up or down bars and then you are accumulating volume when there are consecutive up/down bars.

      What part of the code specifically is not working as you expect? From what I see, Count is always assigned when there is an up or down bar. I would then expect Count[1] to be a 1 if the last bar is an up bar and a 0 if the last bar is a down bar. Is there a specific case where you see this not to be the case? You can print out Count[0] and Count[1] after you assign Count[0] to see what values they hold.

      Is the issue seen when setting the script to Calculate.OnBarClose, or is this seen with other Calculate modes?

      Could you also attach an export of the script and some steps to reproduce the symptoms? It can help to draw on your screenshots to point out the exact thing you want us to be looking for.

      Exporting as source code - https://ninjatrader.com/support/help...tAsSourceFiles

      I look forward to assisting.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      116 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      61 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      40 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      43 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      82 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X