Support Board
Date/Time: Mon, 23 Dec 2024 16:17:07 +0000
Drawing BidSize/AskSize on Chart - Graph Region 0
View Count: 1687
[2015-10-13 01:35:07] |
User126996 - Posts: 30 |
I'm currently using the Depth of Market Study and the s_UseTool to try to draw the BidSize/AskSize on the chart (Graph Region 0). I've tried to accomplish this in 2 different ways but it keeps on shrinking the chart so the bars are really small. This leads me to believe that I'm identifying the Bid/Ask Size but in the process it is re-aligning or re-scaling the price graph to match the size of the Bid/Ask. How can I add the Bid/Ask Size to graph region 0 without the graph re-scaling? Effort 1: #include "sierrachart.h" #include <math.h> void DrawBidSize(SCStudyGraphRef sc, unsigned int index, float value, unsigned int align){ s_UseTool DrawBidSize; DrawBidSize.Clear(); // reset tool structure for our next use DrawBidSize.DrawingType = DRAWING_TEXT; DrawBidSize.BeginIndex = index; DrawBidSize.BeginValue = value; DrawBidSize.Region = 0; DrawBidSize.Color = COLOR_GREEN; DrawBidSize.TextAlignment = DT_CENTER | align; DrawBidSize.AddMethod = UTAM_ADD_OR_ADJUST; DrawBidSize.LineNumber = 98563214; DrawBidSize.FontSize = 10; sc.UseTool(DrawBidSize); } // Example: DrawBidSize(sc, BidValue[sc.Index], BidSize[sc.Index], DT_RIGHT) SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc) { SCSubgraphRef BidSize = sc.Subgraph[0]; SCSubgraphRef BidValue = sc.Subgraph[1]; SCSubgraphRef AskSize = sc.Subgraph[2]; SCSubgraphRef AskValue = sc.Subgraph[3]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Depth of Market Data"; sc.StudyDescription = "This is a study to display current market depth data. When adding this study, also add the Spreadsheet study to your chart to view the market depth data in a table form on the spreadsheet."; sc.UsesMarketDepthData= 1; BidSize.Name = "Bid Size"; BidSize.DrawStyle = DRAWSTYLE_DASH; BidSize.PrimaryColor = RGB(0,255,0); BidSize.DrawZeros = false; BidValue.Name = "Bid Value"; BidValue.DrawStyle = DRAWSTYLE_HIDDEN; BidValue.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_CENTER | LL_VALUE_ALIGN_FAR_RIGHT ; BidValue.PrimaryColor = COLOR_GREEN; BidValue.SecondaryColorUsed = 1; BidValue.SecondaryColor = COLOR_BLACK; BidValue.DrawZeros = false; AskSize.Name = "Ask Size"; AskSize.DrawStyle = DRAWSTYLE_DASH; AskSize.PrimaryColor = RGB(255,255,0); AskSize.DrawZeros = false; AskValue.Name = "Ask Value"; AskValue.DrawStyle = DRAWSTYLE_TEXT; AskValue.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_CENTER | LL_VALUE_ALIGN_FAR_RIGHT; AskValue.PrimaryColor = COLOR_RED; AskValue.SecondaryColorUsed = 1; AskValue.SecondaryColor = COLOR_BLACK; AskValue.DrawZeros = false; sc.FreeDLL = 1; return; } // Do data processing int& PriorIndex = sc.GetPersistentInt(1); for (int Level = 0; Level < MAX_NUM_DOM_LEVELS; Level++) { if (sc.ArraySize -1 - MAX_NUM_DOM_LEVELS < 0) break; BidSize[sc.ArraySize -1 -Level] = (float) sc.SymbolData->BidDOM[Level].Volume; BidValue[sc.ArraySize -1 -Level] = sc.SymbolData->BidDOM[Level].Price; AskSize[sc.ArraySize -1 -Level] = (float) sc.SymbolData->AskDOM[Level].Volume; AskValue[sc.ArraySize -1 -Level] = sc.SymbolData->AskDOM[Level].Price; } int LastIndex = sc.ArraySize -1 - MAX_NUM_DOM_LEVELS; sc.EarliestUpdateSubgraphDataArrayIndex = LastIndex; if (PriorIndex < LastIndex) { for (int ClearIndex = LastIndex; ClearIndex>= PriorIndex; ClearIndex--) { BidSize[ClearIndex] = 0; BidValue[ClearIndex] = 0; AskSize[ClearIndex] = 0; AskValue[ClearIndex] = 0; } } PriorIndex = (LastIndex >= 0) ? LastIndex : 0; DrawBidSize(sc, BidValue[sc.Index], BidSize[sc.Index], DT_RIGHT); } Effort 2: #include "sierrachart.h" #include <math.h> SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc) { SCSubgraphRef BidSize = sc.Subgraph[0]; SCSubgraphRef BidValue = sc.Subgraph[1]; SCSubgraphRef AskSize = sc.Subgraph[2]; SCSubgraphRef AskValue = sc.Subgraph[3]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Depth of Market Data"; sc.StudyDescription = "This is a study to display current market depth data. When adding this study, also add the Spreadsheet study to your chart to view the market depth data in a table form on the spreadsheet."; sc.UsesMarketDepthData= 1; BidSize.Name = "Bid Size"; BidSize.DrawStyle = DRAWSTYLE_DASH; BidSize.PrimaryColor = RGB(0,255,0); BidSize.DrawZeros = false; BidValue.Name = "Bid Value"; BidValue.DrawStyle = DRAWSTYLE_HIDDEN; BidValue.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_CENTER | LL_VALUE_ALIGN_FAR_RIGHT ; BidValue.PrimaryColor = COLOR_GREEN; BidValue.SecondaryColorUsed = 1; BidValue.SecondaryColor = COLOR_BLACK; BidValue.DrawZeros = false; AskSize.Name = "Ask Size"; AskSize.DrawStyle = DRAWSTYLE_DASH; AskSize.PrimaryColor = RGB(255,255,0); AskSize.DrawZeros = false; AskValue.Name = "Ask Value"; AskValue.DrawStyle = DRAWSTYLE_TEXT; AskValue.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_CENTER | LL_VALUE_ALIGN_FAR_RIGHT; AskValue.PrimaryColor = COLOR_RED; AskValue.SecondaryColorUsed = 1; AskValue.SecondaryColor = COLOR_BLACK; AskValue.DrawZeros = false; sc.FreeDLL = 1; return; } // Do data processing int& PriorIndex = sc.GetPersistentInt(1); for (int Level = 0; Level < MAX_NUM_DOM_LEVELS; Level++) { if (sc.ArraySize -1 - MAX_NUM_DOM_LEVELS < 0) break; BidSize[sc.ArraySize -1 -Level] = (float) sc.SymbolData->BidDOM[Level].Volume; BidValue[sc.ArraySize -1 -Level] = sc.SymbolData->BidDOM[Level].Price; AskSize[sc.ArraySize -1 -Level] = (float) sc.SymbolData->AskDOM[Level].Volume; AskValue[sc.ArraySize -1 -Level] = sc.SymbolData->AskDOM[Level].Price; } int LastIndex = sc.ArraySize -1 - MAX_NUM_DOM_LEVELS; sc.EarliestUpdateSubgraphDataArrayIndex = LastIndex; if (PriorIndex < LastIndex) { for (int ClearIndex = LastIndex; ClearIndex>= PriorIndex; ClearIndex--) { BidSize[ClearIndex] = 0; BidValue[ClearIndex] = 0; AskSize[ClearIndex] = 0; AskValue[ClearIndex] = 0; } } PriorIndex = (LastIndex >= 0) ? LastIndex : 0; if (sc.BaseDataIn[SC_LAST][sc.Index] != BidValue[sc.Index]) { s_UseTool DrawTool; DrawTool.Clear(); // reset tool structure for our next use DrawTool.DrawingType = DRAWING_TEXT; DrawTool.BeginIndex = BidValue[sc.Index]; DrawTool.BeginValue = BidSize[sc.Index]; DrawTool.Region = 0; DrawTool.Color = COLOR_GREEN; DrawTool.TextAlignment = DT_RIGHT; DrawTool.Text.Format("B1: %.2f", BidSize[sc.Index]); DrawTool.AddMethod = UTAM_ADD_OR_ADJUST; DrawTool.LineNumber = 74127913; DrawTool.FontSize = 10; sc.UseTool(DrawTool); } } |
[2015-10-13 04:04:23] |
Sierra Chart Engineering - Posts: 104368 |
You need to set the Scale Range for the study to Independent: https://www.sierrachart.com/index.php?page=doc/doc_Scaling.html Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: