vor ca. einem halben Jahr hast du mir in diesem Thread und bei diesem Indikator geholfen ihn zu modifizieren. Hab den nochmal ausgepackt und festgestellt dass der Alarm nicht richtig funktioniert. Du hattest mir eine Schleife eingebaut die mit einem zugewiesenen Counter arbeitet, den man einstellen kann. Beispiel: Erst ein Pfeil+Signal nach 4 Punkten in Folge. Leider gibt er immer einen Alarm nach 3 Punkten egal was ich einstelle heraus.
Die Pfeile werden richtig angezeigt. Nur der Alarm stimmt nicht. Kannst du dir das nochmal kurz anschauen? Wäre super
Code:
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_minimum -35.0
#property indicator_maximum 35.0
#property indicator_buffers 5
#property indicator_color1 clrDodgerBlue
#property indicator_color2 clrDodgerBlue
#property indicator_color3 clrYellow
#property indicator_color4 clrMagenta
#property indicator_level2 12.0
#property indicator_level3 -12.0
#property indicator_style1 2;
extern int Period =5;
extern ENUM_MA_METHOD MaMethod=MODE_SMA;
extern ENUM_APPLIED_PRICE MaPrice = PRICE_MEDIAN;
extern double Level =24.0;
extern int ArrowSize =2;
extern int ArrowcodeBUY =225;
extern int ArrowcodeSELL =226;
extern string ArrowcodeLink ="http://forex-tutor.com/mql4/arrows4.png";
extern color ArrowColorSELL =clrYellow;
extern color ArrowColorBUY =clrMagenta;
extern int Counter =4;
extern bool alertsOn = true;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;
extern bool alertsNotification = false;
double AboveBuff[],ShortBuff[],LongBuff[],BelowBuff[];
double RSIBuffer[];
int act_bars;
int cntlong = 0;
int cntshort = 0;
string prefix="SimilarFx";
datetime alertcandle,lastalertime,arrowcandle;
// ---
int init() {
SetIndexBuffer(0, AboveBuff); SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 2); // Lime Above 0
SetIndexBuffer(1, BelowBuff); SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 2); // Lime Below 0
SetIndexBuffer(2, ShortBuff); SetIndexStyle(2, DRAW_ARROW, EMPTY, 2); SetIndexArrow(2, 108); // Red
SetIndexBuffer(3, LongBuff); SetIndexStyle(3, DRAW_ARROW, EMPTY, 2); SetIndexArrow(3, 108); // Blue
SetIndexLabel(0, "Above");
SetIndexLabel(1, "Below");
SetIndexLabel(2, "SHORT");
SetIndexLabel(3, "LONG");
SetLevelStyle(STYLE_DOT, 0, SteelBlue);
IndicatorShortName(" S.toFx MTN BARS COUNTER ARROW ");
return (0);
}
// ---
int deinit() {
ObjectDeleteByPrefix(prefix);
return(0);
}
// ---
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)
{
if(Bars!=act_bars){
doAlert(whichBar,"down");
act_bars=Bars;}
}
if (LongBuff[whichBar] != EMPTY_VALUE)
{
if(Bars!=act_bars){
doAlert(whichBar,"up");
act_bars=Bars;}
}
}
}
}
void doAlert(int forBar, string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[forBar]) {
previousAlert = doWhat;
previousTime = Time[forBar];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," SimilarFxMNT signal ",Counter," BARS ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol()," SimilarFxMNT "),message);
if (alertsSound) PlaySound("alert2.wav");
if (alertsNotification) SendNotification(message);
}
}
void DrawArrow(string name,string direction,int shifts,string desc){
int anchor=0;
int arrowcode=0;
double price=0;
color mycolor=clrNONE;
//if(Time[shifts]>arrowcandle){
if(direction=="SELL"){anchor=ANCHOR_BOTTOM;arrowcode=ArrowcodeSELL;price=High[shifts]+iATR(NULL,0,5,shifts)/2;mycolor=ArrowColorSELL;}
if(direction=="BUY"){anchor=ANCHOR_TOP;arrowcode=ArrowcodeBUY;price=Low[shifts]-iATR(NULL,0,5,shifts)/2;mycolor=ArrowColorBUY;}
if(ObjectFind(name)<0){ObjectCreate(name,OBJ_ARROW,0,0,0);
ObjectSetInteger(0,name,OBJPROP_WIDTH,ArrowSize);
}
ObjectSetInteger(0,name,OBJPROP_ANCHOR,anchor);
ObjectSet(name,OBJPROP_PRICE1,price);
ObjectSet(name,OBJPROP_TIME1,Time[shifts]);
ObjectSetInteger(0,name,OBJPROP_ARROWCODE,arrowcode);
ObjectSetInteger(0,name,OBJPROP_COLOR,mycolor);
ObjectSetString(0,name,OBJPROP_TEXT,desc);
arrowcandle=Time[shifts];
//}
}
void ObjectDeleteByPrefix(string myprefix)
{
string ObjName;
int strLength = StringLen(myprefix);
int Count = 0;
while (Count < ObjectsTotal()) {
ObjName = ObjectName(Count);
if (StringSubstr(ObjName, 0, strLength) != myprefix) Count++;
else ObjectDelete(ObjName);
}
}