Support Board
Date/Time: Tue, 26 Nov 2024 05:54:37 +0000
[Programming Help] - ACSIL programming assistance request
View Count: 491
[2024-01-04 05:18:30] |
User183724 - Posts: 183 |
ACSIL programming assistance request I'm attempting to use the sc.ZigZag function sc.ZigZag() option 2 SCFloatArrayRef ZigZag (SCFloatArrayRef InputDataHigh, SCFloatArrayRef InputDataLow, SCSubgraphRef Out, float ReversalPercent, int StartIndex); Auto-looping only. I've attached my code below. Ive attempted to use sc.BaseData and sc.BaseDataIn (with inputs) but neither are producing results in the subgraph. any assistance appreciated Tim code follows. /*==========================================================================*/ // The top of every source code file must include this line #include "sierrachart.h" // Name of the custom study. SCDLLName("ZigZag111") /*==========================================================================*/ SCSFExport scsf_ZigZag111(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_ZigZag1 = sc.Subgraph[0]; // SCInputRef Input_InputData1 = sc.Input[1]; // un comment these to use with inputs below if used // SCInputRef Input_InputData2 = sc.Input[2]; if(sc.SetDefaults) { sc.GraphName="ZigZag11"; sc.AutoLoop = 1; sc.GraphRegion = 0; Subgraph_ZigZag1.Name="ZigZag1"; Subgraph_ZigZag1.DrawStyle = DRAWSTYLE_LINE; Subgraph_ZigZag1.PrimaryColor = RGB(0,255,0); Subgraph_ZigZag1.DrawZeros = false; /* // un comment these to use with inputs below if used Input_InputData1.Name = "Input Data1"; Input_InputData1.SetInputDataIndex(SC_HIGH); Input_InputData2.Name = "Input Data2"; Input_InputData2.SetInputDataIndex(SC_LOW); */ return; } float ReversalPercent = 0.17; // change here for now as req // un comment this to use with inputs above if used // sc.ZigZag(sc.BaseDataIn[Input_InputData1.GetInputDataIndex()], sc.BaseDataIn[Input_InputData2.GetInputDataIndex()], Subgraph_ZigZag1, ReversalPercent, sc.Index); sc.ZigZag(sc.BaseData[SC_HIGH], sc.BaseData[SC_LOW], Subgraph_ZigZag1, ReversalPercent, sc.Index); // /* SCString MessageString; MessageString.Format("Subgraph_ZigZag1 %f sc_Index %d" , Subgraph_ZigZag1[sc.Index], sc.Index); sc.AddMessageToLog(MessageString, 0); // */ } /*==========================================================================*/ nothing follows |
[2024-01-04 16:56:26] |
mkata - Posts: 103 |
Notice the last parameter of the function states: int StartIndex. You are currently starting the function on every bar with sc.Index. If you wish to start at the beginning of the chart, use 0. Also you may need to multiply ReversalPercent by .01 based on your needs (that is how Sierra does it) float ReversalPercent = 0.17 * .01; |
[2024-01-04 17:22:00] |
User431178 - Posts: 541 |
Also, take a look at how the Zig Zag study is written in studies7.cpp (acs_source folder), maybe it helps. How to Build an Advanced Custom Study from Source Code: Searching for Source Code for Sierra Chart Built-In Studies |
[2024-01-04 17:51:28] |
User183724 - Posts: 183 |
thx for your reply(s). I tried changing sc.Index to 0 and I tried adding the *01 but I have the same problem. the subgraph isn't populating or i've got something wrong with the message to log statement. Ive reduced my code to min (removed all the line generation lines) and posted it below. i did look at studies7.cpp example. its a non autoloop example and the rest of my study is autoloop so im trying to keep it all the same. from studies7.cpp.... case 1: sc.ZigZag( sc.BaseData[Input_DataHigh.GetInputDataIndex()], sc.BaseData[Input_DataLow.GetInputDataIndex()], Subgraph_ZigZagLine, CalcIndex, Input_ReversalPercent.GetFloat() * 0.01f, ZigZagStartIndex); thx tim code follows // The top of every source code file must include this line #include "sierrachart.h" // Name of the custom study. SCDLLName("ZigZag111") /*==========================================================================*/ SCSFExport scsf_ZigZag111(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_ZigZag1 = sc.Subgraph[0]; if(sc.SetDefaults) { sc.AutoLoop = 1; sc.GraphRegion = 0; return; } float ReversalPercent = 0.5 * 0.01f; // change here for now as req sc.ZigZag(sc.BaseData[SC_HIGH], sc.BaseData[SC_LOW], Subgraph_ZigZag1, ReversalPercent, 0); // /* SCString MessageString; MessageString.Format("Subgraph_ZigZag1 %f sc_Index %d" , Subgraph_ZigZag1, sc.Index); sc.AddMessageToLog(MessageString, 0); // */ } /*==========================================================================*/ nothing follows |
[2024-01-04 19:55:46] |
mkata - Posts: 103 |
You may simply need to turn your message parameter to ON. sc.AddMessageToLog(MessageString, 1); |
[2024-01-04 22:39:38] |
User719512 - Posts: 264 |
You might try MessageString.Format("Subgraph_ZigZag1 %f sc_Index %d" , Subgraph_ZigZag1[sc.Index], sc.Index); or for better formatting MessageString.Format("Subgraph_ZigZag1 %.02f sc_Index %d" , Subgraph_ZigZag1[sc.Index], sc.Index); For my code, I use ZigZag2, but I do know that sample in studies7 works for either. As I recall, the values in your Subgraph_ZigZag1[sc.Index] will be -1, 0, or 1, so you probably don't want to display those in same region as the main chart. As for your own use, changing to sc.AddMessageToLog(MessageString, 1); |
[2024-01-05 05:17:33] |
User183724 - Posts: 183 |
thanks for the reply(S) i made the recommended changes. the only difference i noticed when using sc.AddMessageToLog(MessageString, 1); instead of sc.AddMessageToLog(MessageString, 0); is the 1 forces the message log to open where i have to open the message log if i use the 0. the change didnt appear to have any bearing my problem. my latest code follows... my original code is commented and the changes were included code follows // The top of every source code file must include this line #include "sierrachart.h" // Name of the custom study. SCDLLName("ZigZag111") /*==========================================================================*/ SCSFExport scsf_ZigZag111(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_ZigZag1 = sc.Subgraph[0]; if(sc.SetDefaults) { sc.AutoLoop = 1; return; } float ReversalPercent = 0.5 * 0.01f; // change here for now as req sc.ZigZag(sc.BaseData[SC_HIGH], sc.BaseData[SC_LOW], Subgraph_ZigZag1, ReversalPercent, 0); SCString MessageString; //MessageString.Format("Subgraph_ZigZag1 %f sc_Index %d" , Subgraph_ZigZag1, sc.Index); MessageString.Format("Subgraph_ZigZag1 %.02f sc_Index %d" , Subgraph_ZigZag1[sc.Index], sc.Index); // sc.AddMessageToLog(MessageString, 0); sc.AddMessageToLog(MessageString, 0); end of code below is the last 3 lines of my message log. the only difference is the formatting ... thanks User719512 Chart: MESH24-CME [C][M] 1500 Volume #4 | Study: Custom DLL Study | Subgraph_ZigZag1 0.00 sc_Index 2642 | 2024-01-04 23:06:27.279 Chart: MESH24-CME [C][M] 1500 Volume #4 | Study: Custom DLL Study | Subgraph_ZigZag1 0.00 sc_Index 2642 | 2024-01-04 23:06:28.687 Chart: MESH24-CME [C][M] 1500 Volume #4 | Study: Custom DLL Study | Subgraph_ZigZag1 0.00 sc_Index 2642 | 2024-01-04 23:06:31.972 the problem appears to be the subgraph isnt populating. I ran other studies with the message log code on them and they work as they are supposed to so Im kind of stumped if you have a working example please share. thanx |
[2024-01-05 07:46:38] |
User431178 - Posts: 541 |
Your code from the first post works fine when you remove the startindex variable (it defaults to 0 anyways). See attached image. /*==========================================================================*/ SCSFExport scsf_ZigZag111(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_ZigZag1 = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "ZigZag11"; sc.AutoLoop = 1; sc.GraphRegion = 0; Subgraph_ZigZag1.Name = "ZigZag1"; Subgraph_ZigZag1.DrawStyle = DRAWSTYLE_LINE; Subgraph_ZigZag1.PrimaryColor = RGB(0, 255, 0); Subgraph_ZigZag1.DrawZeros = false; return; } float ReversalPercent = 0.5 * 0.01f; // change here for now as req sc.ZigZag(sc.BaseData[SC_HIGH], sc.BaseData[SC_LOW], Subgraph_ZigZag1, ReversalPercent); SCString MessageString; //MessageString.Format("Subgraph_ZigZag1 %f sc_Index %d" , Subgraph_ZigZag1, sc.Index); MessageString.Format("Subgraph_ZigZag1 %.02f sc_Index %d", Subgraph_ZigZag1[sc.Index], sc.Index); // sc.AddMessageToLog(MessageString, 0); sc.AddMessageToLog(MessageString, 0); } below is the last 3 lines of my message log
It's no good looking at only a few message entries, and there are clearly values in the subgraphs as otherwise the image previously attached would have no lines present. Date Time Of Last Edit: 2024-01-05 07:49:05
|
zigzag.png / V - Attached On 2024-01-05 07:43:48 UTC - Size: 35.93 KB - 59 views |
[2024-01-05 15:37:18] |
User183724 - Posts: 183 |
thanks User431178 (and everybody else). I still dont know what i was doing wrong but i finally got working
|
To post a message in this thread, you need to log in with your Sierra Chart account: