Code:
// ---
int start() {
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=MathMin(Bars-counted_bars,Bars-1);
for (int i = limit; i >=0; i--)
{
//double Temp = 0.0; for (int j = i; j < i + Per; j++) Temp += (High[j] + Low[j]) / 2.0;
//rsi:
double Main =iMA(NULL,0,Period,0,MaMethod,MaPrice,i) ;//Temp / Per;
// Temp = 0.0; for (j = i; j < i + Per; j++) Temp += High[j] - Low[j];
double Minr = 0.2 * iATR(NULL,0,Period,i);//(Temp / Per);
if (Minr!=0)
{
AboveBuff[i] = 3.0 * (High[i] - Main) / Minr;
BelowBuff[i] = 3.0 * (Low[i] - Main) / Minr;
}
ShortBuff[i] = EMPTY_VALUE;
LongBuff[i] = EMPTY_VALUE;
//so in etwa, ohne es getestet zu haben!
//in den externen Variablen z.B. int Counter = 3; definieren
//außerhalb start() in den globalen Vairablen die Variablen int cntlong = 0; und cntshort = 0; deklarieren und initialisieren
if (AboveBuff[i] > Level) {
cntlong = 0;
cntshort++;
if (cntshort == Counter) {
ShortBuff[i] = Level+1;
DrawArrow(prefix+Time[i],"SELL",i,"down");
cntshort = 0;
}
} else cntshort = 0;
if (BelowBuff[i] < -Level) {
cntshort = 0;
cntlong++;
if (cntlong == Counter) {
LongBuff[i] = -(Level+1);
DrawArrow(prefix+Time[i],"BUY",i,"up");
cntlong = 0;
}
} else cntlong = 0;
}
manageAlerts();
return(0);
}
//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
void manageAlerts()
{
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1;
if (ShortBuff[whichBar] != EMPTY_VALUE || LongBuff[whichBar] != EMPTY_VALUE)
{
if (ShortBuff[whichBar] != EMPTY_VALUE==OP_SELL)
{
if(Bars!=act_bars){
doAlert(whichBar,"down");
act_bars=Bars;}
}
if (LongBuff[whichBar] != EMPTY_VALUE==OP_BUY)
{
if(Bars!=act_bars){
doAlert(whichBar,"up");
act_bars=Bars;}
}
}
}
}
Ja, das hättest Du gleich schreiben sollen.
Na dann, viel Erfolg!
traderdoc