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

Looping through all prices in a bar

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

    Looping through all prices in a bar

    Hello,

    My drawing tool aims to gather and separate the order flow activity in each value area of a bar (above, at or below value). To do this I have to manually calculate the value area and then group each price and that price's data respectively. The tool will only be used on a daily volumetric bar, and on one bar at a time.
    So far, the infrastructure is complete for the drawing tool and I have managed to isolate the price and the volume of the VPOC of the bar. My problem is figuring out how to correctly loop through all the prices and adding the volume to correctly find the value area. Provided is a sample of what I have written:

    double tickSize = AttachedTo.Instrument.MasterInstrument.TickSize;
    double BarLow = myBars.Bars.GetLow(startIdx);
    double BarHigh = myBars.Bars.GetHigh(startIdx);
    double p;
    ​
    for (p = barHigh; p >= barLow; p -= tickSize)
    {
    dailyBarVPOCVolume = barsType.Volumes[i].GetMaximumVolume(null, out vpocPrice);
    }

    Here I am able to get the volume of the VPOC and the price as shown in the picture for day 03.

    Should I use the vpoc as an anchor point to then loop though prices above and below then add their volumes to calculate the Value Area (until the "Vol%ofTotalDay Print is approx. 70%) or can it be calculated another way?
    Attached Files

    #2
    Hello Don22Trader1,

    It appears you have the loop correct to loop from the high to low of a volumetric bar.

    The 'i' variable appears to be undefined so, not sure if this is meant to be baseBars.Count - 1.

    This thread will remain open for any community members that would like to assist with custom logic and calculations.

    Adding the volume from each price row seems sensible.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    6 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Yesterday, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Working...
    X