Hallo,
- Wir können hier Deutsch reden :)
- Überprüf die Klammersetzung das (long) wandelt nur POSITION_TYPE_SELL um!
- Wenn das Problem in den beiden if liegt, dann verwende den Debugger (s.u.) markiere die einzelnen Elemente der if und hole sie mit Shift+F9 ins Fenster des Debuggers und schau ob sie sind wie beabsichtigt:
https://www.metatrader5.com/de/metaeditor/help/development/debug
Zur Fehlerbehebung von MQL5-Programmen (Debugging) : https://www.mql5.com/de/articles/654
Einführung in MQL5: Schreiben eines einfachen Expert Advisor und benutzerdefinierten Indikators, Siehe Ende: Starten und Debuggen https://www.mql5.com/de/articles/35
Die Fehlerverarbeitung und Protokollierung in MQL5: https://www.mql5.com/de/articles/2041
https://www.mql5.com/de/articles/272
Fehler finden und Protokollierung https://www.mql5.com/de/articles/150
Übrigens, es gibt fast nicht, was nicht schon für MQ programmiert wurde,
also vielleicht erst einmal suchen, statt es selber versuchen, kopieren ist viel schneller als probieren.
- www.metatrader5.com
Could someone please help me to understand why my EA is not closing the position?
if (type == (long)POSITION_TYPE_BUY && rt[0].close < ma[0] || rt[0].close < sar[0] || adx_main[0] < 25)
signal = true;
if(type==(long)POSITION_TYPE_SELL && rt[0].close > ma[0] || rt[0].close > sar[0] || adx_main[0] < 25)
signal=true;
The EA shall check - in a long situtation - if the CLOSE is either below the MA[10] or below the SAR or the ADX have fallen below 25.
See attached screenshot. My expectation would is that the code shall close the position on the 22nd of Oct 2015 EURUSD (Daily).
Thanks for the support!Hallo,
zu wenig Code. Da fällt noch Close Funktion.
- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
Could someone please help me to understand why my EA is not closing the position?
if (type == (long)POSITION_TYPE_BUY && rt[0].close < ma[0] || rt[0].close < sar[0] || adx_main[0] < 25)
signal = true;
if(type==(long)POSITION_TYPE_SELL && rt[0].close > ma[0] || rt[0].close > sar[0] || adx_main[0] < 25)
signal=true;
The EA shall check - in a long situtation - if the CLOSE is either below the MA[10] or below the SAR or the ADX have fallen below 25.
See attached screenshot. My expectation would is that the code shall close the position on the 22nd of Oct 2015 EURUSD (Daily).
Thanks for the support!