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 Tim-c, Today, 03:54 AM
      0 responses
      3 views
      0 likes
      Last Post Tim-c
      by Tim-c
       
      Started by FrancisMorro, Today, 03:24 AM
      0 responses
      2 views
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,771 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      31 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      945 views
      0 likes
      Last Post spwizard  
      Working...
      X