Hoch auslesen von X Kerzen
Einen schönen Tag an alle.
Eine Frage an die Fachwelt. Bei einem EA würde ich gerne das Hoch von X Kerzen bis zur 3.letzten in einer Funktion auslesen.. Leider zeigt er aber das Hoch von der letzten Kerze an, was nur sehr selten die Höchste ist. Ich versuchte es mit 2 Codes. Was gebe ich da falsch ein??? //--------------------------------------------------------------------+ // Hoch Auslesen Versuch 1 | //--------------------------------------------------------------------+ double Hoch_Wert(double Hoch_Wert) { double H; int cnt,Kerzen_Zahl; Kerzen_Zahl = 18; // extern int Kerzen_Zahl = 18; H=iHigh(NULL,0,Kerzen_Zahl); Kerzen_Zahl=Kerzen_Zahl-1; for( cnt = Kerzen_Zahl;cnt>2;cnt--) { if(iHigh(NULL,0,cnt)>H)H=iHigh(NULL,60,cnt); } Hoch_Wert=H; return (Hoch_Wert); } //--------------------------------------------------------------------+ // Hoch Auslesen Versuch 2 | //--------------------------------------------------------------------+ double Hoch_Wert(double Hoch_Wert) { double H; int cnt,Kerzen_Zahl; Kerzen_Zahl = Kerzen_Anzahl; cnt = 2; Kerzen_Zahl = 18; // extern int Kerzen_Zahl = 18; H=iHigh(NULL,0,cnt); Kerzen_Zahl=Kerzen_Zahl-1; for( cnt ;cnt>Kerzen_Zahl;cnt++) { if(iHigh(NULL,0,cnt)>H)H=iHigh(NULL,60,cnt); } Hoch_Wert=H; return (Hoch_Wert); } |
Es geht einfacher:
iLow(NULL,PERIOD_M1,iLowest(NULL,PERIOD_M1,MODE_LO W,10,0)); iHigh(NULL,PERIOD_M1,iHighest(NULL,PERIOD_M1,MODE_ HIGH,10,0)); findet Tiefs und Hochs der letzten 10 Bars. Statt der 10 kannst Du Deine Anzahl Bars einsetzen, bzw. Die Periode PERIOD_M1 ist nur als Beispiel, 0 ist Current. |
iHighest
Returns the shift of the maximum value over a specific number of bars depending on type. int iHighest( string symbol, // symbol int timeframe, // timeframe int type, // timeseries int count, // cont int start // start ); Parameters symbol [in] Symbol the data of which should be used for search. NULL means the current symbol. timeframe [in] Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe. type [in] Series array identifier. It can be any of the Series array identifier enumeration values. count=WHOLE_ARRAY [in] Number of bars (in direction from the start bar to the back one) on which the search is carried out. start=0 [in] Shift showing the bar, relative to the current bar, that the data should be taken from. Returned value The shift of the maximum value over a specific number of bars or -1 if error. To check errors, one has to call the GetLastError() function. Example: double val; //--- calculating the highest value on the 20 consecutive bars in the range //--- from the 4th to the 23rd index inclusive on the current chart int val_index=iHighest(NULL,0,MODE_HIGH,x2,x1); if(val_index!=-1) val=High[val_index]; else PrintFormat("Error in call iHighest. Error code=%d",GetLastError()); Daraus ergibt sich, das man beginnebd bei einem Offset von x1 kerzen z.B. x2 vorherige Kerzenhochs prüfen kann und den Höchstwert bekommt. Ist doch easy. Die MQL-Doku ist doch super, so wie sie ist. LG jOE |
Ein Dankeschön für die schnelle Antworten.
Aber wie kann ich die Zählung erst bei der 3 oder 4 Kerze beginnen lassen und dann Auswerten bis zur 10 Kerze? Dieser Codes iLow(NULL,PERIOD_M1,iLowest(NULL,PERIOD_M1,MODE_LO W,10,0)); liest ja von der 1 bis zur 10 das Hoch aus. Bei mir sollen aber erst ab der 3 Ausgelesen werden. Wie ist das zu ändern ?? |
iLow(NULL,PERIOD_M1,iLowest(NULL,PERIOD_M1,MODE_LO W,8,3));
traderdoc |
Suppii,
leuft wie Geschmiert. Danke schön. |
Alle Zeitangaben in WEZ +2. Es ist jetzt 15:10 Uhr. |
Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum