Support Board
Date/Time: Sun, 22 Dec 2024 19:09:39 +0000
[User Discussion] - ACSIL REPLAY PROBLEM
View Count: 1984
[2015-08-26 19:05:27] |
User668659 - Posts: 6 |
Hello! I've recently notice that a study i made with some moving averages signals doesn't work well in realtime/replay(Accurate trading system back test mode). If i disconnect the live data and apply the study it works without a problem. The study draw some lines above/under price based on two movavg positions and draw a triangle above/under the crossing point of another two movavg. After a replay or working in real time appear signals that doesn't exist. Maybe there is something i don't know that changes in ACSIL under a replay/real time. I left the screenshots before/after replay. Here is the code: #include "sierrachart.h" #include "scstudyfunctions.h" #define RED RGB(255,0,0) #define BLUE RGB(0,128,255) SCDLLName("MovSlope") SCSFExport scsf_MovSlope(SCStudyInterfaceRef sc){ SCSubgraphRef MovSlope1 = sc.Subgraph[0]; SCSubgraphRef MovSlope2 = sc.Subgraph[1]; SCSubgraphRef MovSlope3 = sc.Subgraph[2]; SCSubgraphRef MovSlope4 = sc.Subgraph[3]; SCSubgraphRef MovSlope5 = sc.Subgraph[4]; SCSubgraphRef MovSlope6 = sc.Subgraph[5]; SCSubgraphRef MovSlope7 = sc.Subgraph[6]; SCSubgraphRef MovSlope8 = sc.Subgraph[7]; if (sc.SetDefaults){ sc.GraphName = "MovSlope"; sc.StudyDescription = "MovSlope"; sc.AutoLoop = 1; sc.FreeDLL = 0; sc.GraphRegion = 0; MovSlope1.Name = "MV1"; MovSlope1.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope1.LineStyle = LINESTYLE_SOLID; MovSlope1.LineWidth = 3; MovSlope1.DrawZeros = false; MovSlope2.Name = "MV2"; MovSlope2.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope2.LineStyle = LINESTYLE_SOLID; MovSlope2.LineWidth = 3; MovSlope2.DrawZeros = false; MovSlope3.Name = "MV3"; MovSlope3.DrawStyle = DRAWSTYLE_LINE_SKIPZEROS; MovSlope3.LineStyle = LINESTYLE_SOLID; MovSlope3.LineWidth = 3; MovSlope3.DrawZeros = false; MovSlope4.Name = "MV4"; MovSlope4.DrawStyle = DRAWSTYLE_LINE_SKIPZEROS; MovSlope4.LineStyle = LINESTYLE_SOLID; MovSlope4.LineWidth = 3; MovSlope4.DrawZeros = false; MovSlope5.Name = "MV5"; MovSlope5.DrawStyle = DRAWSTYLE_TRIANGLEDOWN; MovSlope5.LineWidth = 3; MovSlope5.DrawZeros = false; MovSlope6.Name = "MV6"; MovSlope6.DrawStyle = DRAWSTYLE_TRIANGLEUP; MovSlope6.LineWidth = 3; MovSlope6.DrawZeros = false; MovSlope7.Name = "MV7"; MovSlope7.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope7.LineStyle = LINESTYLE_SOLID; MovSlope7.LineWidth = 3; MovSlope7.DrawZeros = false; MovSlope8.Name = "MV8"; MovSlope8.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope8.LineStyle = LINESTYLE_SOLID; MovSlope8.LineWidth = 3; MovSlope8.DrawZeros = false; sc.Input[1].Name = "Red"; sc.Input[1].SetColor(RED); sc.Input[2].Name = "Blue"; sc.Input[2].SetColor(BLUE); return; } SCFloatArrayRef Last = sc.Close; sc.SimpleMovAvg(Last, MovSlope1, sc.Index, 5); sc.SimpleMovAvg(Last, MovSlope2, sc.Index, 10); sc.SimpleMovAvg(Last, MovSlope7, sc.Index, 12); sc.SimpleMovAvg(Last, MovSlope8, sc.Index, 16); float mov1 = MovSlope1[sc.Index]; float mov2 = MovSlope2[sc.Index]; float mov7 = MovSlope7[sc.Index]; float mov8 = MovSlope8[sc.Index]; if (mov1 > mov2) { MovSlope3[sc.Index] = mov1 + 6.0f; MovSlope3.DataColor[sc.Index] = sc.Input[2].GetColor(); } else if (mov1 < mov2) { MovSlope4[sc.Index] = mov1 - 6.0f; MovSlope4.DataColor[sc.Index] = sc.Input[1].GetColor(); } if ((MovSlope7[sc.Index - 1] > MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] < MovSlope8[sc.Index])){ MovSlope5[sc.Index] = mov1 + 8.5f; MovSlope5.DataColor[sc.Index] = sc.Input[1].GetColor(); } else if ((MovSlope7[sc.Index - 1] < MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] > MovSlope8[sc.Index])){ MovSlope6[sc.Index] = mov1 - 8.5f; MovSlope6.DataColor[sc.Index] = sc.Input[2].GetColor(); } } |
[2015-08-26 19:34:43] |
Sierra Chart Engineering - Posts: 104368 |
We cannot analyze your code. Do you notice a problem when you just perform a normal chart replay? We recommend simplifying the study down to the absolute minimum and keep it very simple and then gradually make changes/additions until you discover where the problem is. So you need to simplify the study down to this line only after the SetDefaults code block: sc.SimpleMovAvg(Last, MovSlope1, sc.Index, 5); They gradually make the changes until you see were the problem is. 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 |
[2015-08-27 04:11:07] |
User668659 - Posts: 6 |
During a normal chart replay remains the same. I think i found the problem. Look at the images 1 and 2, this false signal is after the second half of the example image. I simplify the code, the only thing it does is drawing a triangle at the crossing points between both sma. In the image 1 there is a signal but the value of the sma MV1 is: 1898.430 but MV2 is: 1898.460. MV1 still is < than MV2. Evidently there is a problem of precision, how can i increment the precision? At the image 1 this is false: ((MovSlope1[sc.Index - 1] < MovSlope2[sc.Index - 1]) && (MovSlope1[sc.Index] > MovSlope2[sc.Index]))
#include "sierrachart.h" #include "scstudyfunctions.h" #define RED RGB(255,0,0) #define BLUE RGB(0,128,255) SCDLLName("MovSlope") SCSFExport scsf_MovSlope(SCStudyInterfaceRef sc){ SCSubgraphRef MovSlope1 = sc.Subgraph[0]; SCSubgraphRef MovSlope2 = sc.Subgraph[1]; SCSubgraphRef MovSlope3 = sc.Subgraph[2]; SCSubgraphRef MovSlope4 = sc.Subgraph[3]; SCSubgraphRef MovSlope5 = sc.Subgraph[4]; SCSubgraphRef MovSlope6 = sc.Subgraph[5]; SCSubgraphRef MovSlope7 = sc.Subgraph[6]; SCSubgraphRef MovSlope8 = sc.Subgraph[7]; if (sc.SetDefaults){ sc.GraphName = "MovSlope"; sc.StudyDescription = "MovSlope"; sc.AutoLoop = 1; sc.FreeDLL = 0; sc.GraphRegion = 0; MovSlope1.Name = "MV1"; MovSlope1.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope1.LineStyle = LINESTYLE_SOLID; MovSlope1.LineWidth = 3; MovSlope1.DrawZeros = false; MovSlope2.Name = "MV2"; MovSlope2.DrawStyle = DRAWSTYLE_HIDDEN; MovSlope2.LineStyle = LINESTYLE_SOLID; MovSlope2.LineWidth = 3; MovSlope2.DrawZeros = false; MovSlope3.Name = "MV3"; MovSlope3.DrawStyle = DRAWSTYLE_LINE_SKIPZEROS; MovSlope3.LineStyle = LINESTYLE_SOLID; MovSlope3.LineWidth = 3; MovSlope3.DrawZeros = false; MovSlope4.Name = "MV4"; MovSlope4.DrawStyle = DRAWSTYLE_LINE_SKIPZEROS; MovSlope4.LineStyle = LINESTYLE_SOLID; MovSlope4.LineWidth = 3; MovSlope4.DrawZeros = false; sc.Input[1].Name = "Red"; sc.Input[1].SetColor(RED); sc.Input[2].Name = "Blue"; sc.Input[2].SetColor(BLUE); return; } SCFloatArrayRef Last = sc.Close; sc.SimpleMovAvg(Last, MovSlope1, sc.Index, 5); sc.SimpleMovAvg(Last, MovSlope2, sc.Index, 10); if ((MovSlope1[sc.Index - 1] > MovSlope2[sc.Index - 1]) && (MovSlope1[sc.Index] < MovSlope2[sc.Index])) { MovSlope3[sc.Index] = MovSlope2[sc.Index] + 6.0f; MovSlope3.DataColor[sc.Index] = sc.Input[2].GetColor(); } else if ((MovSlope1[sc.Index - 1] < MovSlope2[sc.Index - 1]) && (MovSlope1[sc.Index] > MovSlope2[sc.Index])) { MovSlope4[sc.Index] = MovSlope2[sc.Index] - 6.0f; MovSlope4.DataColor[sc.Index] = sc.Input[1].GetColor(); } } |
example.png / V - Attached On 2015-08-27 04:02:50 UTC - Size: 44.18 KB - 313 views |
[2015-08-27 05:53:06] |
ejtrader - Posts: 688 |
You can look at the following function: sc.FormattedEvaluate(value1, sc.BasedOnGraphValueFormat, EQUAL_OPERATOR, value2, sc.BasedOnGraphValueFormat) |
[2015-08-27 13:49:12] |
User668659 - Posts: 6 |
I'll try it ejtrader, thanks! But i'll really would like to know why this simple condition: (MovSlope1[sc.Index] > MovSlope2[sc.Index]) works while live data is disconnected, and fails once in a while during a replay or working with live data. Can someone explain this to me?
|
[2015-08-27 14:47:37] |
Marek F - Posts: 244 |
Maybe used the function: sc.GetBarHasClosedStatus() for perform calculations on a fully completed bar, resolve your issue? http://www.sierrachart.com/index.php?l=doc/doc_ACSIL_Members_Functions.html#scGetBarHasClosedStatus |
[2015-08-27 16:01:08] |
User668659 - Posts: 6 |
Thanks sampater! I tried it and help me understand a little more the problem. If i use this: if(sc.GetBarHasClosedStatus(Index)==BHCS_BAR_HAS_CLOSED)
Then i'll no longer see false signals after the bar colsed, but i need the signal in real time while both sma cross. So during the period of a bar i would like to be able to draw the signal while it's true but the moment after it's no longer true i would like to remove the signal(during or after the current bar).How can i check in real time if a condition it's no longer true and then remove the statement(in this case drawing with a subgraph)?I mean before the bar has closed, because maybe i can check at the end of the bar if the condition it's no longer true, but i need to remove the statement at the moment the condition turns false. I need to see during the period of the last bar only the result of the last execution. Can i delete the result of the last execution during the period of the current bar at the current execution? |
[2015-08-29 11:53:58] |
Marek F - Posts: 244 |
during the period of a bar i would like to be able to draw the signal while it's true but the moment after it's no longer true i would like to remove the signal
You need to set to 0 the Subgraphs of signal if both sma cross is not true. This your code from post #1: if ((MovSlope7[sc.Index - 1] > MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] < MovSlope8[sc.Index]))
{ MovSlope5[sc.Index] = mov1 + 8.5f; MovSlope5.DataColor[sc.Index] = sc.Input[1].GetColor(); } else if ((MovSlope7[sc.Index - 1] < MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] > MovSlope8[sc.Index])) { MovSlope6[sc.Index] = mov1 - 8.5f; MovSlope6.DataColor[sc.Index] = sc.Input[2].GetColor(); } change to: if ((MovSlope7[sc.Index - 1] > MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] < MovSlope8[sc.Index]))
{ MovSlope5[sc.Index] = mov1 + 8.5f; MovSlope5.DataColor[sc.Index] = sc.Input[1].GetColor(); } else { MovSlope5[sc.Index] = 0; MovSlope5.DataColor[sc.Index] = RGB(0,0,0); } if ((MovSlope7[sc.Index - 1] < MovSlope8[sc.Index - 1]) && (MovSlope7[sc.Index] > MovSlope8[sc.Index])) { MovSlope6[sc.Index] = mov1 - 8.5f; MovSlope6.DataColor[sc.Index] = sc.Input[2].GetColor(); } else { MovSlope6[sc.Index] = 0; MovSlope6.DataColor[sc.Index] = RGB(0,0,0); } Marek |
To post a message in this thread, you need to log in with your Sierra Chart account: