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 techgetgame, Yesterday, 11:42 PM
      0 responses
      8 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Yesterday, 11:36 PM
      0 responses
      2 views
      0 likes
      Last Post sephichapdson  
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,613 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Yesterday, 05:56 PM
      0 responses
      10 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      20 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X