Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 18:18:34 +0000



Post From: ACSIL Custom Autotrading System assistance

[2024-08-09 15:01:29]
User357489 - Posts: 72
Ok i have taken an alternative approach;

i already made a study that "highlights" when bid/ask pullingstacking value >= user defined threshold.

#include "sierrachart.h"

SCDLLName("Flash Genie")

SCSFExport scsf_FlashGenie(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "Flash Genie";
sc.GraphRegion = 0;
sc.AutoLoop = 1; // Auto-loop enabled

sc.Input[0].Name = "Volume Threshold";
sc.Input[0].SetInt(100); // Default threshold value

sc.Input[1].Name = "Number of Levels";
sc.Input[1].SetInt(5); // Default number of levels

sc.Input[2].Name = "Bid Highlight Color";
sc.Input[2].SetColor(RGB(0, 0, 255)); // Default bid highlight color

sc.Input[3].Name = "Ask Highlight Color";
sc.Input[3].SetColor(RGB(255, 0, 0)); // Default ask highlight color

return;
}

int threshold = sc.Input[0].GetInt();
int numLevels = sc.Input[1].GetInt();
COLORREF bidHighlightColor = sc.Input[2].GetColor();
COLORREF askHighlightColor = sc.Input[3].GetColor();
s_MarketDepthEntry depthEntry;

// Remove existing highlights
sc.DeleteACSChartDrawing(sc.ChartNumber, TOOL_DELETE_ALL, 0);

for (int level = 0; level < numLevels; ++level)
{
// Check Ask levels
if (sc.GetAskMarketDepthEntryAtLevel(depthEntry, level))
{
double pullingStackingAsk = sc.GetAskMarketDepthStackPullValueAtPrice(depthEntry.Price);
if (pullingStackingAsk >= threshold)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.BeginValue = depthEntry.Price - sc.TickSize / 2;
tool.EndValue = depthEntry.Price + sc.TickSize / 2;
tool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
tool.EndDateTime = sc.BaseDateTimeIn[0];
tool.Color = askHighlightColor;
tool.SecondaryColor = askHighlightColor;
tool.TransparencyLevel = 70;
tool.LineWidth = 1;
sc.UseTool(tool);
}
}

// Check Bid levels
if (sc.GetBidMarketDepthEntryAtLevel(depthEntry, level))
{
double pullingStackingBid = sc.GetBidMarketDepthStackPullValueAtPrice(depthEntry.Price);
if (pullingStackingBid >= threshold)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.BeginValue = depthEntry.Price - sc.TickSize / 2;
tool.EndValue = depthEntry.Price + sc.TickSize / 2;
tool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
tool.EndDateTime = sc.BaseDateTimeIn[0];
tool.Color = bidHighlightColor;
tool.SecondaryColor = bidHighlightColor;
tool.TransparencyLevel = 70;
tool.LineWidth = 1;
sc.UseTool(tool);
}
}
}
}

so another bright idea was to replace the logic of checking the pullingstacking to the volume at price from the VBP (still set at askvolume-bidvolume), i spoonfed AI the sc.Get.... from the documentation and we created:
#include "sierrachart.h"

SCDLLName("Volume Difference Highlight with Market Depth")

SCSFExport scsf_VolumeDifferenceHighlightWithMarketDepth(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "Volume Difference Highlight with Market Depth";
sc.GraphRegion = 0;
sc.AutoLoop = 1;

sc.Input[0].Name = "Volume Profile Study ID";
sc.Input[0].SetInt(7); // Set this to the actual study ID of the Volume Profile

sc.Input[1].Name = "Bid Highlight Color";
sc.Input[1].SetColor(RGB(0, 255, 0)); // Default bid highlight color

sc.Input[2].Name = "Ask Highlight Color";
sc.Input[2].SetColor(RGB(255, 0, 0)); // Default ask highlight color

sc.Input[3].Name = "Number of Levels to Check";
sc.Input[3].SetInt(5); // Number of bid/ask levels to check

return;
}

int volumeProfileStudyID = sc.Input[0].GetInt();
COLORREF bidHighlightColor = sc.Input[1].GetColor();
COLORREF askHighlightColor = sc.Input[2].GetColor();
int numLevelsToCheck = sc.Input[3].GetInt();

s_MarketDepthEntry depthEntry;
s_VolumeAtPriceV2 volumeAtPriceData;

// Remove existing highlights
sc.DeleteACSChartDrawing(sc.ChartNumber, TOOL_DELETE_ALL, 0);

// Get the number of price levels in the VBP profile
int numPriceLevels = sc.GetNumPriceLevelsForStudyProfile(volumeProfileStudyID, 0);

// Loop through Ask levels and highlight based on volume difference
for (int level = 0; level < numLevelsToCheck; ++level)
{
if (sc.GetAskMarketDepthEntryAtLevel(depthEntry, level))
{
double price = depthEntry.Price;

for (int priceIndex = 0; priceIndex < numPriceLevels; ++priceIndex)
{
if (sc.GetVolumeAtPriceDataForStudyProfile(volumeProfileStudyID, 0, priceIndex, volumeAtPriceData))
{
double vbpPrice = volumeAtPriceData.PriceInTicks * sc.TickSize;

if (fabs(vbpPrice - price) < sc.TickSize / 2)
{
double volumeDifference = volumeAtPriceData.AskVolume - volumeAtPriceData.BidVolume;

if (volumeDifference < 0) // Highlight Ask levels with negative volume difference
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.BeginValue = price - sc.TickSize / 2;
tool.EndValue = price + sc.TickSize / 2;
tool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
tool.EndDateTime = sc.BaseDateTimeIn[0];
tool.Color = askHighlightColor;
tool.SecondaryColor = askHighlightColor;
tool.TransparencyLevel = 70;
tool.LineWidth = 1;
sc.UseTool(tool);
}
break;
}
}
}
}
}

// Loop through Bid levels and highlight based on volume difference
for (int level = 0; level < numLevelsToCheck; ++level)
{
if (sc.GetBidMarketDepthEntryAtLevel(depthEntry, level))
{
double price = depthEntry.Price;

for (int priceIndex = 0; priceIndex < numPriceLevels; ++priceIndex)
{
if (sc.GetVolumeAtPriceDataForStudyProfile(volumeProfileStudyID, 0, priceIndex, volumeAtPriceData))
{
double vbpPrice = volumeAtPriceData.PriceInTicks * sc.TickSize;

if (fabs(vbpPrice - price) < sc.TickSize / 2)
{
double volumeDifference = volumeAtPriceData.AskVolume - volumeAtPriceData.BidVolume;

if (volumeDifference > 0) // Highlight Bid levels with positive volume difference
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.BeginValue = price - sc.TickSize / 2;
tool.EndValue = price + sc.TickSize / 2;
tool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
tool.EndDateTime = sc.BaseDateTimeIn[0];
tool.Color = bidHighlightColor;
tool.SecondaryColor = bidHighlightColor;
tool.TransparencyLevel = 70;
tool.LineWidth = 1;
sc.UseTool(tool);
}
break;
}
}
}
}
}
}
Kinda works, but doesnt work. please see attached screenshots. The user can input the StudyID for the VBP (i tried altering this and it indeed stopped highlighting completely so it recognised the VBP study - i think ) ps ignore the orange highlight, this is from the working study mentioned first. so you see it has highlighted all of the bid levels ( i realise in this example, the bid level VBP values are indeed all >0, however they dont "delete" when bid levels has VBP<0), however not included the ask levels and also the logic for vol>0, vol<0 hasnt been implemented correctly, if the VBP value on the bid levels is <0, then theres no need to highlight so ignore. likewise with VBP value on ask levels >0, ignore. so only ask levels will highlight when VBP values <0 and vice versa.

Gone over the docs and read thru what each member does and structure etc and hit the wall again (learning has taken place this week however thanks to your guidance and help! so again , TYVM!)


EDIT: PS; taken this approach to make "standalone" conditions, make sure they work as intended, them throw them all together (logically of course) think ive been running before i can walk here, so this could prove a beneficial course of action
Date Time Of Last Edit: 2024-08-09 15:04:56
imageimage.png / V - Attached On 2024-08-09 15:01:04 UTC - Size: 9.09 KB - 43 views
imageimage1.png / V - Attached On 2024-08-09 15:01:08 UTC - Size: 7.27 KB - 38 views