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 DayTradingDEMON, Today, 09:28 AM
      2 responses
      15 views
      0 likes
      Last Post DayTradingDEMON  
      Started by Stanfillirenfro, Today, 07:23 AM
      6 responses
      22 views
      0 likes
      Last Post Stanfillirenfro  
      Started by navyguy06, Today, 09:28 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      8 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by helpwanted, Today, 03:06 AM
      2 responses
      22 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X