Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 20:34:41 +0000



Post From: having a problem with abs and plotting

[2015-10-08 08:18:32]
KhaosTrader - Posts: 128
Hi,

I agree, that's a good idea to make a barebones study. So I have done that, and still have problem. Please let me know what I am doing wrong, or how to debug it...

Thank you in advance..

// test bed
SCSFExport scsf_JeffTest(SCStudyInterfaceRef sc)



{



SCSubgraphRef EMA_Medium = sc.Subgraph[2];
SCSubgraphRef EMA_Long = sc.Subgraph[3];

SCSubgraphRef MaxM_100percent_Upper= sc.Subgraph[6];




// Set configuration variables

if (sc.SetDefaults)

{

// Set the configuration and defaults
sc.GraphName = "Jeff Test";
sc.StudyDescription = "Averages used to assit predicting price patterns.";
sc.GraphRegion = 0;
sc.AutoLoop = 1;
sc.AlertOnlyOncePerBar = true;
  sc.FreeDLL = 1;

// Set the color, style and line width for the subgraph
  
  

  MaxM_100percent_Upper.Name = "MMove 100% Upper";
  MaxM_100percent_Upper.PrimaryColor = RGB(20,77,255);
  MaxM_100percent_Upper.DrawStyle = DRAWSTYLE_LINE;
  MaxM_100percent_Upper.LineStyle = LINESTYLE_SOLID;
  MaxM_100percent_Upper.LineWidth = 5;



  EMA_Medium.Name = "EMA Medium";
  EMA_Medium.PrimaryColor = RGB(255,0,0);
  EMA_Medium.DrawStyle = DRAWSTYLE_LINE;
  EMA_Medium.LineStyle = LINESTYLE_SOLID;
  EMA_Medium.LineWidth = 2;

  EMA_Long.Name = "EMA Long";
  EMA_Long.PrimaryColor = RGB(0,0,255);
  EMA_Long.DrawStyle = DRAWSTYLE_LINE;
  EMA_Long.LineStyle = LINESTYLE_SOLID;
  EMA_Long.LineWidth = 2;


  

  
  return;

}

// Do data processing
// Calculate a simple moving average from the base data




sc.ExponentialMovAvg(sc.Close, EMA_Medium, 50);
sc.ExponentialMovAvg(sc.Close, EMA_Long, 200);

float EMAMedium = EMA_Medium[sc.Index];
float EMALong = EMA_Long[sc.Index];


MaxM_100percent_Upper[sc.Index]= abs(EMAMedium - EMALong) ;

//MaxMove_100percent_Upper[sc.Index]= ( EMA_Medium[sc.Index-1] - EMA_Long[sc.Index-1]) ; /// 1.0f;





}