Support Board
Date/Time: Tue, 22 Apr 2025 17:34:58 +0000
Post From: Sierra unable to Plot correctly.
[2025-01-16 12:23:46] |
User431178 - Posts: 654 |
Here is one solution. SCSFExport scsf_ApexVolumeAtPriceStudy(SCStudyInterfaceRef sc) { auto& sg_Green = sc.Subgraph[0]; auto& sg_Red = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "Apex Volume at Price Study"; sc.StudyDescription = "Detects conditions for Green and Red Candles based on POC."; sc.AutoLoop = 0; sc.GraphRegion = 0; sc.MaintainVolumeAtPriceData = 1; sg_Green.Name = "Green"; sg_Green.DrawStyle = DRAWSTYLE_SQUARE; sg_Green.PrimaryColor = RGB(0, 255, 0); sg_Green.LineWidth = 5; sg_Red.Name = "Red"; sg_Red.DrawStyle = DRAWSTYLE_SQUARE; sg_Red.PrimaryColor = RGB(255, 0, 0); sg_Red.LineWidth = 5; return; } if (sc.VolumeAtPriceForBars->GetNumberOfBars() < sc.ArraySize) return; for (auto idx = sc.UpdateStartIndex; idx < sc.ArraySize; ++idx) { if (sc.GetBarHasClosedStatus(idx) != BHCS_BAR_HAS_CLOSED) continue; const auto numLevels = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(idx); if (numLevels == 0) continue; const s_VolumeAtPriceV2* p_VAP = nullptr; auto pocIdx{ 0 }; auto pocVol{ 0 }; for (auto lvl = 0; lvl < numLevels; ++lvl) { if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(idx, lvl, &p_VAP, true)) continue; if (!p_VAP) continue; if (p_VAP->Volume > pocVol) { pocVol = p_VAP->Volume; pocIdx = lvl; } } if (sc.Close[idx] > sc.Open[idx]) { if (pocIdx >= 0 && pocIdx <= 3) sg_Green[idx] = sc.Low[idx] - 2 * sc.TickSize; } else if (sc.Close[idx] < sc.Open[idx]) { if (pocIdx >= 4 && pocIdx <= 7) sg_Red[idx] = sc.High[idx] + 2 * sc.TickSize; } } } |