Login Page - Create Account

Support Board


Date/Time: Tue, 22 Apr 2025 17:55:06 +0000



Post From: Sierra unable to Plot correctly.

[2025-01-16 13:55:56]
cmet - Posts: 690
Ignore the haters. AI is very useful and autonomous agents will take over all coding tasks within 3 years (you can already make a reasonable version of one with Projects). Keep learning.

This is what you're looking for:

#include "sierrachart.h"

SCDLLName("VPOC Candle Coloring")

SCSFExport scsf_VPOCCandleColoring(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_GreenFill = sc.Subgraph[0];
SCSubgraphRef Subgraph_RedFill = sc.Subgraph[1];

SCInputRef Input_TickRangeTop = sc.Input[0];
SCInputRef Input_TickRangeBottom = sc.Input[1];

if (sc.SetDefaults)
{
sc.GraphName = "VPOC Candle Coloring";
sc.GraphRegion = 0;
sc.AutoLoop = 0;
sc.MaintainVolumeAtPriceData = 1;
sc.DrawZeros = false;

Subgraph_GreenFill.Name = "Green Fill";
Subgraph_GreenFill.DrawStyle = DRAWSTYLE_COLOR_BAR_CANDLE_FILL;
Subgraph_GreenFill.PrimaryColor = RGB(0, 255, 0);
Subgraph_GreenFill.DrawZeros = false;

Subgraph_RedFill.Name = "Red Fill";
Subgraph_RedFill.DrawStyle = DRAWSTYLE_COLOR_BAR_CANDLE_FILL;
Subgraph_RedFill.PrimaryColor = RGB(255, 0, 0);
Subgraph_RedFill.DrawZeros = false;

Input_TickRangeTop.Name = "VPOC Ticks from Top";
Input_TickRangeTop.SetInt(2);
Input_TickRangeTop.SetIntLimits(1, 100);

Input_TickRangeBottom.Name = "VPOC Ticks from Bottom";
Input_TickRangeBottom.SetInt(2);
Input_TickRangeBottom.SetIntLimits(1, 100);

return;
}

float TickSize = sc.TickSize;

for (int i = sc.UpdateStartIndex; i < sc.ArraySize; i++)
{
s_VolumeAtPriceV2 VolumeAtPrice;
sc.GetPointOfControlPriceVolumeForBar(i, VolumeAtPrice);

float VPOC = static_cast<float>(sc.TicksToPriceValue(VolumeAtPrice.PriceInTicks));
float BarHigh = sc.High[i];
float BarLow = sc.Low[i];

Subgraph_GreenFill[i] = 0;
Subgraph_RedFill[i] = 0;

if (VPOC >= BarHigh - (Input_TickRangeTop.GetInt() * TickSize))
{
Subgraph_GreenFill[i] = 1;
}
else if (VPOC <= BarLow + (Input_TickRangeBottom.GetInt() * TickSize))
{
Subgraph_RedFill[i] = 1;
}
}
}

This actually colors bars.

Image has Volume Point of Control for Bars as a reference.

Number of ticks customizable through inputs.
Date Time Of Last Edit: 2025-01-16 13:58:06
imagevpoc_coloring.jpg / V - Attached On 2025-01-16 13:56:28 UTC - Size: 127.14 KB - 36 views