Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 00:21:51 +0000



Post From: ACSIL REPLAY PROBLEM

[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();
  }
  

}

image1.png / V - Attached On 2015-08-27 04:02:37 UTC - Size: 13.62 KB - 330 views
image2.png / V - Attached On 2015-08-27 04:02:43 UTC - Size: 14.04 KB - 320 views
imageexample.png / V - Attached On 2015-08-27 04:02:50 UTC - Size: 44.18 KB - 313 views