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

BuySellVolume returni

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

    BuySellVolume returni

    How could I inhibit the return to zero on the first tick of each bar so that the actual tally of alSells and alBuys are displayed all the way ? I tried to have that part of code as a comment but sometimes one of the two variables become < 0.

    protected override void OnBarUpdate()
    {
    if (CurrentBar < activeBar)
    {
    Values[0].Set((double)alSells[CurrentBar]);
    Values[1].Set((double)alBuys[CurrentBar]);
    return;
    }
    else if (CurrentBar != activeBar)
    {
    //
    /* previousVol = 0;
    alBuys.Insert(Math.Max(activeBar, 0), Historical ? 0 : buys);
    alSells.Insert(Math.Max(activeBar, 0), Historical ? 0 : sells);
    buys = 0;
    sells = 0;
    activeBar = CurrentBar; */
    }
    Last edited by grd974; 10-10-2007, 11:41 AM.

    #2
    Could you clarify the intent of your post?
    RayNinjaTrader Customer Service

    Comment


      #3
      Sure.

      I modified the BuySellVolume indicator so as to watch one red pricemarker and one green pricemarker displaying red trade volume and green trade volume from the Time & Sales window. The code is by now :

      <<<
      if (firstPaint)
      firstPaint = false;
      else
      {
      double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;
      if (Close[0] >= GetCurrentAsk())
      {
      buys += tradeVol;
      positive.Set(tradeVol);
      negative.Set(0);
      }
      else if (Close[0] <= GetCurrentBid())
      {
      sells += tradeVol;
      negative.Set(tradeVol);
      positive.Set(0);
      }
      }
      previousVol = Volume[0];
      if (!firstPaint && !Historical)
      {
      Values[0].Set(negative[0]);
      Values[1].Set(positive[0]);
      }
      >>>

      The fact that each pricemarker is cleared at the beginning of avery new bar bothers me : I want buys and sells to keep on suming up every relevant incoming tradevol and I don't want to change my chart from a x minutes bar to a y ticks bar.
      I if could prevent buys and sells from being cleared, my rationale would be the following :
      initialize Bsubtractbase = 0 and Ssubtractbase = 0
      on bar update do
      {
      buys = buys + tradeVol - Bsubtractbase
      tickcount = tickcount +1
      if remainder of (tickcount/myparam) = 0 then Bsubtractbase= buys
      sells= sells + tradeVol - Ssubtractbase
      tickcount = tickcount +1
      if remainder of (tickcount/myparam) = 0 then Ssubtractbase= sells
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by TraderIqbal, 10-20-2023, 10:12 AM
      2 responses
      118 views
      0 likes
      Last Post Funnywo
      by Funnywo
       
      Started by Creamers, 04-27-2024, 05:32 AM
      12 responses
      72 views
      0 likes
      Last Post Creamers  
      Started by fredericlebre, Today, 01:19 AM
      0 responses
      7 views
      0 likes
      Last Post fredericlebre  
      Started by TraderJA, Today, 12:06 AM
      0 responses
      10 views
      0 likes
      Last Post TraderJA  
      Started by SnailHorn, Yesterday, 10:49 PM
      0 responses
      9 views
      0 likes
      Last Post SnailHorn  
      Working...
      X