Support Board
Date/Time: Thu, 13 Nov 2025 23:26:55 +0000
[Programming Help] - Number Bars Calculated Values
View Count: 36
| [2025-11-13 15:23:41] |
| trader88 - Posts: 18 |
|
Dear Support, I am working on automated trading system using Footprint charts and Number Bars Calculated Values (NBCV). As I am reding values from NBSV I follow indexing as I can see in Subgraphs: Ask Volume Total -- SG6 Bid Volume Total -- SG7 ..... Total Volume -- SG13 ===== What is the correct way to read Ask Volume and Bid Volume from Numbers Bars Calculated Values study when Display Mode is set to 'Number Bars'? I am currently reading SG6 for Ask and SG7 for Bid, but SG7 contains negative values which doesn't make sense for Bid Volume. Problem: SG7 (mapped to "Bid Volume Total") contains negative values in 10 out of 50 bars (min=-2.00 max=234.00), which doesn't make sense for Bid Volume. Display Mode: "Number Bars" <----- Unable to Change this Data Evidence: - SG6 (AskVol): min=41.00 max=829.00, negs=0/50 (looks correct) - SG7 (BidVol): min=-2.00 max=234.00, negs=10/50 (getting negatives!) - SG5: min=31.00 max=764.00, negs=0/50 (possible correct BidVol?) NOTE: Values Displayed on NBCV Studies in my chart are correct and there are NO negative values where we know only positive make sense. ----- This is a code I am reading NBCV // Lambda to fetch NBCV subgraphs from micro chart auto fetchNBCV = [&](int sg, SCFloatArray& out) -> bool { sc.GetStudyArrayFromChartUsingID(microChartNum, nbcvStudyID, sg, out); return out.GetArraySize() > 0; }; // NOTE: We compute Total Volume = Ask + Bid ourselves instead of reading from study // This avoids SG mapping brittleness and guarantees non-negative values // Fetch all NBCV subgraphs we need // NOTE: Total Volume computed as Ask + Bid (primary), SG13 fetched for validation only SCFloatArray aBidAskDiff; // SG1: Ask Volume - Bid Volume Difference (delta) SCFloatArray aAskVol; // SG6: Ask Volume Total SCFloatArray aBidVol; // SG7: Bid Volume Total ← THIS IS GETTING NEGATIVES! SCFloatArray aTotVol; // SG13: Total Volume (validation/fallback only) SCFloatArray aPOCVol; // SG20: Point Of Control Volume SCFloatArray aPOCPrice; // SG42: Point Of Control Value (price) SCFloatArray aVolPerSec; // SG36: Volume / Sec SCFloatArray aUpDnDiff; // SG50: Up/Down Tick Volume Difference SCFloatArray aNumTrades; // SG12: Number of Trades SCFloatArray aAvgVolPerTrade; // SG15: Average Volume per Trade SCFloatArray aHiLoRange; // SG41: High Low Value (bar range) SCFloatArray aPullbackHigh; // SG37: High Pullback Ask/Bid Vol Diff SCFloatArray aPullbackLow; // SG38: Low Pullback Ask/Bid Vol Diff // Fetch all required NBCV subgraphs if (!fetchNBCV(1, aBidAskDiff) || !fetchNBCV(6, aAskVol) || !fetchNBCV(7, aBidVol) || !fetchNBCV(20, aPOCVol) || !fetchNBCV(42, aPOCPrice) || !fetchNBCV(36, aVolPerSec) || !fetchNBCV(50, aUpDnDiff) || !fetchNBCV(12, aNumTrades) || !fetchNBCV(15, aAvgVolPerTrade) || !fetchNBCV(41, aHiLoRange) || !fetchNBCV(37, aPullbackHigh) || !fetchNBCV(38, aPullbackLow)) { // Fail if any critical SG missing return; } ..... // Compute Total Volume = Ask + Bid (guaranteed non-negative) for (int i = microStartIndex; i <= microEndIndex; i++) { if (i >= 0 && i < aAskVol.GetArraySize() && i < aBidVol.GetArraySize()) { float ask = aAskVol; float bid = aBidVol; // Defensive clamp (should never happen, but safety first) if (ask < 0) { sc.AddMessageToLog(SCString().Format("Negative AskVol (%.2f) clamped to 0 at idx=%d", ask, i), 1); ask = 0; } if (bid < 0) { sc.AddMessageToLog(SCString().Format("Negative BidVol (%.2f) clamped to 0 at idx=%d", bid, i), 1); bid = 0; } currentVolume += (ask + bid); // USE COMPUTED TOTAL } } |
| [2025-11-13 15:44:21] |
| User431178 - Posts: 809 |
|
I am working on automated trading system using Footprint charts and Number Bars Calculated Values (NBCV). As I am reding values from NBSV I follow indexing as I can see in Subgraphs: Ask Volume Total -- SG6 Bid Volume Total -- SG7 ..... Total Volume -- SG13 ===== What is the correct way to read Ask Volume and Bid Volume from Numbers Bars Calculated Values study when Display Mode is set to 'Number Bars'? I am currently reading SG6 for Ask and SG7 for Bid, but SG7 contains negative values which doesn't make sense for Bid Volume. Problem: SG7 (mapped to "Bid Volume Total") contains negative values in 10 out of 50 bars (min=-2.00 max=234.00), which doesn't make sense for Bid Volume. // Fetch all required NBCV subgraphs if (!fetchNBCV(1, aBidAskDiff) || !fetchNBCV(6, aAskVol) || !fetchNBCV(7, aBidVol) || !fetchNBCV(20, aPOCVol) || !fetchNBCV(42, aPOCPrice) || !fetchNBCV(36, aVolPerSec) || !fetchNBCV(50, aUpDnDiff) || !fetchNBCV(12, aNumTrades) || !fetchNBCV(15, aAvgVolPerTrade) || !fetchNBCV(41, aHiLoRange) || !fetchNBCV(37, aPullbackHigh) || !fetchNBCV(38, aPullbackLow)) { // Fail if any critical SG missing return; } The subgraphs are zero indexed, so you are not getting the data that you think you are. Ask Volume Total -- SG6 --> index = 5 (not 6) Bid Volume Total -- SG7 --> index = 6 (not 7) |
| [2025-11-13 18:57:48] |
| trader88 - Posts: 18 |
|
Thank you so much. IS this true for all other studies and subgraphs. How about for Volume Profile: POC - Point of Control -- SG2 and so on So it to get data programmatically for POC I must use index 1? |
To post a message in this thread, you need to log in with your Sierra Chart account:
