#property copyright "berani2"
#property link "https://www.mql5.com"
#property version "1.00"
#include <Trade\Trade.mqh>
- When I use the OrderSelect() ,it always returns false. why???
- OnInit and OnTick never called when ea on offline chart
- ROBOT RADING WITH CCI(20)
R you sure your broker is using ORDER_FILLING_FOK ?
tp is not set right. here is an example:
Global:
input int magicNumber = 1; // Magic Number input double Lots = 0.1; // Lot Size input int SL_Pips = 100; // Stop Loss in Pips input int TP_Pips = 200; // Take Profit in Pips input ENUM_ORDER_TYPE_FILLING BROKER_FILLING_TYPE = ORDER_FILLING_IOC; // Broker Filling Type double Ask, Bid;
OnTick:
Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
buy signal example:
if (buySignal && PositionsTotal() == 0) { double lotSize = Lots; double sl = Ask - SL_Pips * _Point; double tp = Ask + TP_Pips * _Point; MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); ZeroMemory(result); request.action = TRADE_ACTION_DEAL; request.symbol = _Symbol; request.volume = lotSize; request.type = ORDER_TYPE_BUY; request.type_filling = BROKER_FILLING_TYPE; request.price = Ask; if (sl >= 0){ request.sl = NormalizeDouble(sl, _Digits); } if (tp >= 0){ request.tp = NormalizeDouble(tp, _Digits); } request.deviation = 3; request.magic = magicNumber; request.comment = "SuperTrend Buy"; if (OrderSend(request, result)) { Print("Buy order sent successfully."); lastTradeTime = TimeCurrent(); } else { Print("Failed to send buy order. Error: ", GetLastError()); } }
sell signal example:
if (sellSignal && PositionsTotal() == 0) { double lotSize = Lots; double sl = Bid + SL_Pips * _Point; double tp = Bid - TP_Pips * _Point; MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); ZeroMemory(result); request.action = TRADE_ACTION_DEAL; request.symbol = _Symbol; request.volume = lotSize; request.type = ORDER_TYPE_SELL; request.type_filling = BROKER_FILLING_TYPE; request.price = Bid; if (sl >= 0) { request.sl = NormalizeDouble(sl, _Digits); } if (tp >= 0) { request.tp = NormalizeDouble(tp, _Digits); } request.deviation = 3; request.magic = 0; request.comment = "SuperTrend Sell"; if (OrderSend(request, result)) { Print("Sell order sent successfully."); lastTradeTime = TimeCurrent(); } else { Print("Failed to send sell order. Error: ", GetLastError()); } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register