I would have suggested the same thing to display a notch where the POC would lie:
- Add a plot, use a PlotStyle like Hash
- Assign the POC value in SetValues()
protected override void OnBarUpdate()
{
// if (CurrentBar <= 2) return;
Print("BarsArray[1].Count - 1 - CurrentBars[1] : " +(BarsArray[1].Count - 1 - CurrentBars[1]));
Print("BarsArray[0].IsTickReplay : " +BarsArray[0].IsTickReplay);
Print("State == State.Realtime : " +(State == State.Realtime));
Print("CurrentBars[0] > 0 : " +(CurrentBars[0] > 0));
Print("lastBar != CurrentBars[0] : " +(lastBar != CurrentBars[0]));
Print("State == State.Historical : " +(State == State.Historical));
if (BarsInProgress == 0)
{
// This lets us know what processing mode we are in
// if indexOffset == 0 then we are in 'realtime processing mode'
// if indexOffset is > 0 then we are in 'historical processing mode'
int indexOffset = BarsArray[1].Count - 1 - CurrentBars[1];
Print("indexOffset : " +indexOffset);
Print("indexOffset == 0 : " +(indexOffset == 0));
Print("indexOffset > 0 : " +(indexOffset > 0));
// If we are not Calculate.OnBarClose and we are in Realtime processing mode
if (IsFirstTickOfBar && Calculate != Calculate.OnBarClose && (State == State.Realtime || BarsArray[0].IsTickReplay))
{
// We always get the last tick after the primary triggers OBU so we update the last bar
if (CurrentBars[0] > 0)
SetValues(1);
// We have the last tick of the bar added so now we can reset
if (BarsArray[0].IsTickReplay || State == State.Realtime && indexOffset == 0)
ResetValues(false);
}
// We only set the value on the primary to preserve external programmatic access to plot as well as indicator-as-input cases
SetValues(0);
// If we are Calculate.OnBarClose or we are in Historical processing mode, we are already update to date on the 1 tick series so we reset here
if (Calculate == Calculate.OnBarClose || (lastBar != CurrentBars[0] && (State == State.Historical || State == State.Realtime && indexOffset > 0)))
ResetValues(false);
lastBar = CurrentBars[0];
}
else if (BarsInProgress == 1)
{
// The more granular series will open the new session so we have to reset any session related stuff here
if (BarsArray[1].IsFirstBarOfSession)
ResetValues(true);
// We only calculate values from the 1 tick series
CalculateValues(false);
}
}
private void CalculateValues(bool forceCurrentBar)
{
// This lets us know what processing mode we are in
// if indexOffset == 0 and State is Realtime then we are in 'realtime processing mode'
// if indexOffset is > 0 then we are in 'historical processing mode'
int indexOffset = BarsArray[1].Count - 1 - CurrentBars[1];
bool inTransition = State == State.Realtime && indexOffset > 1;
// For Calculate.OnBarClose in realtime processing we have to advance the index on the tick series to not be one tick behind
// The means, at the end of the 'transition' (where State is Realtime but we are still in historical processing mode) -> we have to calculate two ticks (CurrentBars[1] and CurrentBars[1] + 1)
if (!inTransition && lastInTransition && !forceCurrentBar && Calculate == Calculate.OnBarClose)
CalculateValues(true);
bool useCurrentBar = State == State.Historical || inTransition || Calculate != Calculate.OnBarClose || forceCurrentBar;
// This is where we decide what index to use
int whatBar = useCurrentBar ? CurrentBars[1] : Math.Min(CurrentBars[1] + 1, BarsArray[1].Count - 1);
// This is how we get the right tick values
double volume = BarsArray[1].GetVolume(whatBar);
double price = BarsArray[1].GetClose(whatBar);
// Accumulate volume
if (price == price)
{
combined += volume;
if (TempCombinedVolumeDict.ContainsKey(price))
TempCombinedVolumeDict[price] += volume;
else
TempCombinedVolumeDict.Add(price, volume);
}
Dictionary<double, double> dctTemp = new Dictionary<double, double>();
KeyValuePair<double, double> max = new KeyValuePair<double, double>();
for (double p = Low[0]; p <= High[0]; p += TickSize)
{
if (TempCombinedVolumeDict.ContainsKey(p))
// Print(String.Format("Ask: {0} {1} {2}", p, TempCombinedVolumeDict[p], Time[0]));
foreach (KeyValuePair<double, double> pair in TempCombinedVolumeDict.OrderBy(key => key.Value))
{
dctTemp.Add(pair.Key, pair.Value);
// Print(String.Format("Ask: {0} {1} {2}", pair.Key, pair.Value, Time[0]));
}
// KeyValuePair<double, double> max = new KeyValuePair<double, double>();
foreach (var kvp in dctTemp)
{
if (kvp.Value > max.Value)
max = kvp;
}
// Print(String.Format("max: {0} {1}", max.Key, max.Value, Time[0]));
Print("B. indexOffset : " +indexOffset);
Print("b1. indexOffset == 0 : " +(indexOffset == 0));
Print("b2. indexOffset > 0 : " +(indexOffset > 0));
Print("inTransition : " +(inTransition));
Print("State == State.Realtime && indexOffset > 1 : " +(State == State.Realtime && indexOffset > 1));
Print("C. BarsArray[1].Count - 1 - CurrentBars[1] : " +(BarsArray[1].Count - 1 - CurrentBars[1]));
Print("c1. BarsArray[0].IsTickReplay : " +BarsArray[0].IsTickReplay);
Print("c2. State == State.Realtime : " +(State == State.Realtime));
Print("c3. CurrentBars[0] > 0 : " +(CurrentBars[0] > 0));
Print("c4. lastBar != CurrentBars[0] : " +(lastBar != CurrentBars[0]));
Print("c.5 State == State.Historical : " +(State == State.Historical));
}
DateTime myStartTime = BarsArray[0].GetTime(CurrentBars[0]).Subtract(TimeSpan.FromSeconds(7));
DateTime myEndTime = BarsArray[0].GetTime(CurrentBars[0]).Subtract(TimeSpan.FromSeconds(2));
if (Time[0] >= myStartTime && Time[0] <= myEndTime)
{
//OnBarClose
Draw.Line(this, "tag1"+CurrentBar, true, 0, max.Key, 0, max.Key + (1 * TickSize), Brushes.White, DashStyleHelper.Dash, 5);
}
lastInTransition = inTransition;
}
// Print("BarsArray[0] : " +(BarsArray[0]) + "Time[0] : " + Time[0]);
// Print("CurrentBars[0] : " +(CurrentBars[0]) + "Time[0] : " + Time[0]);
Print("BarsArray[0].GetTime(CurrentBars[0]) : " +(BarsArray[0].GetTime(CurrentBars[0]) + "Time[0] : " + Time[0]));
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
331 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.

Comment