Budapest, Hungary
Posts: 1 since May 2023
Thanks Given: 0
Thanks Received: 0
|
Hi,
I created a code in ACSIL and I would like to ask some assistance how to code an additional condition. What I have done so far is I created three types of moving averages (RSI, EMA39, SMA) and defined a condition accordig to which the color of the bar ha to be changed into green once SMA9 crosses EMA39 from below. Now I want to add a new condition, according to which the crossover is valid only in case the value of RSI was below at 32 at least once in last 15 bars. How to modify the code with this condition? Thanks in advance
Here is the existing code:
#include "sierrachart.h"
SCDLLName("Crossover")
SCSFExport scsf_RSI(SCStudyInterfaceRef sc)
{
SCSubgraphRef RSI = sc.Subgraph[0];
SCSubgraphRef EMA39 = sc.Subgraph[1];
SCSubgraphRef SMA9 = sc.Subgraph[2];
SCSubgraphRef Cross = sc.Subgraph[3];
SCSubgraphRef Subgraph_Cross = sc.Subgraph[4];
if (sc.SetDefaults)
{
// Set the defaults
sc.GraphName = "Crossover";
sc.GraphRegion = 0;
//sc.Subgraph[0].Name = "RSI14";
//sc.Subgraph[1].Name = "EMA39";
//sc.Subgraph[2].Name = "SMA9";
//sc.Subgraph[3].Name = "Cross";
//sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[2].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[3].DrawStyle = DRAWSTYLE_LINE;
Subgraph_Cross.Name = "movavgcross";
Subgraph_Cross.DrawStyle = DRAWSTYLE_COLOR_BAR;
Subgraph_Cross.PrimaryColor = RGB(0,255,0);
sc.AutoLoop = 1;
return;
}
// RSI definíció.
sc.RSI(sc.BaseDataIn[SC_LAST], RSI, MOVAVGTYPE_WILDERS, 14);
// EMA39 definíció.
sc.ExponentialMovAvg(RSI, EMA39, sc.Index, 39);
//SMA9 definíció
sc.SimpleMovAvg(RSI, SMA9, sc.Index, 9);
// Do data processing
if
( (sc.CrossOver(SMA9, EMA39) == CROSS_FROM_BOTTOM)
)
Subgraph_Cross[sc.Index] = 1;
else
Subgraph_Cross[sc.Index] = 0;
}
|