Code:
//
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_style1 STYLE_DOT
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
#property indicator_minimum -30
#property indicator_maximum 30
#property indicator_level1 -20
#property indicator_level2 0
#property indicator_level3 20
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
extern int barsToProcess=100;
double TrendUp[], TrendDn[],SignalUp[];
string indicatorFileName;
string Lizenzcode = "12104499";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//if (AccountNumber() != Lizenzcode) return(INIT_FAILED);
SetIndexBuffer(0,SignalUp);SetIndexStyle(0,DRAW_LINE,0,1,clrBlack);
SetIndexBuffer(1,TrendUp);SetIndexStyle(1,DRAW_LINE,0,2,clrRed);
SetIndexBuffer(2,TrendDn);SetIndexStyle(2,DRAW_LINE,0,2,clrGreen);
indicatorFileName = WindowExpertName();
IndicatorShortName("Score 2020 " + "Signalwert:");
MathSrand(TimeLocal());
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll();
// Löschen wir alle Objekte
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, limit, counted_bars=IndicatorCounted();
limit=Bars-counted_bars;
/*limit= MathMin(Bars-counted_bars,Bars-1);//Bars;//MathMin(Bars-counted_bars,Bars-1);//Bars-counted_bars;
limit=barsToProcess;
if(counted_bars>0)
counted_bars--;
// if(limit>barsToProcess);
*/
//for (i=limit, r=Bars-i-1; i>=0; i--,r++) for(i=limit;i<limit;i++)
for(i=limit;i>=0;i--)
{
double Scoreindex = 0;
double cciclose = iCCI(NULL,0,14,PRICE_CLOSE,i);
if (cciclose < -100) Scoreindex -=5;
if (cciclose > 100) Scoreindex +=5;
double cciopen = iCCI(NULL,0,14,PRICE_OPEN,i);
if (cciopen < -100) Scoreindex -=5;
if (cciopen > 100) Scoreindex +=5;
double rsi = iRSI(NULL,0,14,PRICE_CLOSE,i);
if (rsi < 20) Scoreindex -=5;
if (rsi > 70) Scoreindex +=5;
double stoFastK = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_MAIN ,i);
double stoFastD = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_SIGNAL,i);
if (stoFastK < 20) Scoreindex -=5;
if (stoFastK > 80) Scoreindex +=5;
if (stoFastD < 20) Scoreindex -=5;
if (stoFastD > 80) Scoreindex +=5;
if(Scoreindex>0)TrendUp[i]=DoubleToStr(Scoreindex,2);
if(Scoreindex<0)TrendDn[i]=DoubleToStr(Scoreindex,2);
//if(Scoreindex=0)SignalUp[i]=DoubleToStr(Scoreindex,2);
//ExtCCIBuffer[i]=(ExtPriceBuffer[i]-ExtMovBuffer[i])/dSum;
SignalUp[i]=DoubleToStr(Scoreindex,2);
}
return(0);
}