Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools
Zurück   Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools > Metatrader 4 > Programmierung MQL4

Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4.

Login
Benutzername:
Kennwort:


Statistik
Themen: 4978
Beiträge: 43260
Benutzer: 7.222
Aktive Benutzer: 72
Links: 84
Wir begrüßen unseren neuesten Benutzer: Mane
Mit 2.475 Benutzern waren die meisten Benutzer gleichzeitig online (16.01.20 um 22:38).
Neue Benutzer:
vor einem Tag
- Mane
vor 2 Wochen
- AlbertZiz
vor 2 Wochen
- michak
vor 2 Wochen
- Amateur
vor 2 Wochen
- infos1982

Onlineuser
'Wer ist online' anzeigen Benutzer: 0
Gäste: 174
Gesamt: 174
Team: 0
Team:  
Benutzer:  
Freunde anzeigen

Empfehlungen

Like Tree2Likes
Thema geschlossen
 
Themen-Optionen Thema durchsuchen Ansicht
  #11 (permalink)  
Alt 05.05.16
Benutzerbild von Nap$ter
Neues Mitglied
 
Registriert seit: Jan 2015
Beiträge: 21
Nap$ter befindet sich auf einem aufstrebenden Ast
Standard

Hey Traderdoc,

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);
   }
}
Angehängte Dateien
Dateityp: mq4 SimilarFxMTN_BARS_V5-1.mq4 (7,0 KB, 3x aufgerufen)
Thema geschlossen

Lesezeichen

Stichworte
berechnung kerzen, kerzen einstellbar, kerzenübergreifend, mql4, programmierung, programmierung metatrader

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus




Alle Zeitangaben in WEZ +2. Es ist jetzt 23:32 Uhr.





Suchmaschine - Reisen - Wavesnode - Facebook Forum - Spam Firewall
-----------------------------------------------------------------------------------------------------------------------------
Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
SEO by vBSEO 3.6.1
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum
MetaTrader bzw. MetaTrader 4 und MetaTrader 5 sind eingetragene Marken der MetaQuotes Software Corp.
-----------------------------------------------------------------------------------------------------------------------------