![]() |
|
Startseite | Registrieren | Hilfe | Benutzerliste | Kalender | Suchen | Heutige Beiträge | Alle Foren als gelesen markieren |
Programmierung MQL5 Hier gehts rund ums Programmieren in MQL5. |
![]() |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
![]()
Hallo. Versuche mich an einem EA. Aber leider nimmt er die trade.Sell und trade.buy Funktion leider nicht. Könnte mir dabei jemand behilflich sein wo mein Fehler liegt? Hier der Code.
#include <Trade\Trade.mqh> CTrade trade; input int stopLossPips = 150; // Stop Loss in Pips input int takeProfitPips = 200; // Take Profit in Pips input int trailStopPips = 10; // Trailing Stop in Pips //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // Initialize your EA here return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { // Deinitialize your EA here } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBO L_ASK),_Digits); double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBO L_BID),_Digits); //--- Fractal variables double fractalHigh, fractalLow; string signal=""; fractalHigh = iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 5, 1)); fractalLow = iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 5, 1)); if((iHigh(Symbol(), 0, 2) < iHigh(Symbol(), 0, 1) && iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 0)) && (iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 3) && iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 4))) { fractalHigh = iHigh(Symbol(), 0, 1); signal="sell"; } if((iLow(Symbol(), 0, 2) > iLow(Symbol(), 0, 1) && iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 0)) && (iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 3) && iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 4))) { fractalLow = iLow(Symbol(), 0, 1); signal="buy"; } //--- Buy condition if(fractalLow != 0) { double stopLoss = fractalLow - stopLossPips * _Point; double takeProfit = fractalLow + takeProfitPips * _Point; double trailingStop = fractalLow - trailStopPips * _Point; // Retrieve the current Ask price if (signal =="buy" && PositionsTotal()<1) { // Place buy order here using Ask trade.Buy(0.10,NULL,Ask,(Ask-200 * _Point),(Ask+150 * _Point),NULL, stopLoss, takeProfit, trailingStop); } } //--- Sell condition if(fractalHigh != 0) { double stopLoss = fractalHigh + stopLossPips * _Point; double takeProfit = fractalHigh - takeProfitPips * _Point; double trailingStop = fractalHigh + trailStopPips * _Point; // Retrieve the current Bid price if (signal =="sell" && PositionsTotal()<1) { // Place sell order here using Bid trade.Sell(0.10,NULL,Bid,(Bid+200 * _Point),(Bid-150 * _Point),NULL, stopLoss, takeProfit, trailingStop); } } } |
![]() |
Lesezeichen |
Themen-Optionen | Thema durchsuchen |
Ansicht | |
|
|