Invalid Limit Order executing at Market
Base code:
From EA:
int OnInit(){ // some more code ea.tradeManager.SetDeviationInPoints(2); return(INIT_SUCCEEDED); } void OnTick(){ // some more code ea.manualLot = 1; ea.manualSLValue = 0; ea.manualTPValue = 0; ea.OpenPosition(ORDER_TYPE_SELL_LIMIT, SymbolInfoDouble(_Symbol,SYMBOL_BID) - 20); }
From my EAManager:
bool CEAManager::OpenPosition(ENUM_ORDER_TYPE signal, double priceIn = 0.0, string comment = ""){ bool returnValue = false; // some more code if(signal == ORDER_TYPE_SELL_LIMIT){ if(tradeManager.SellLimit(lot,price,_Symbol,sl,tp,ORDER_TIME_DAY,timelimit,inBotID+"_"+comment)){ parcialRealizada = false; breakeavenRealizado = false; onTickSellCount++; returnValue = true; } } // some more code return returnValue; }
From CTrade
CTrade::CTrade(void) : m_async_mode(false), m_magic(0), m_deviation(2), m_type_filling(ORDER_FILLING_FOK), m_log_level(LOG_LEVEL_ERRORS) { SetMarginMode(); //--- initialize protected data ClearStructures(); //--- check programm mode if(MQL5InfoInteger(MQL5_TESTING)) m_log_level=LOG_LEVEL_NO; if(MQL5InfoInteger(MQL5_OPTIMIZATION)) m_log_level=LOG_LEVEL_NO; }
Contact your broker - this is normal.
Hello guys!
If anyone has the time to help me I will be very grateful.
I have the following problem:
When I send a limit order below market price (which I understand should be rejected) it is being executed at market price.
This happens even with a long distance, in the example I'm using 20pts (40 pips I think, because the step of this asset is 0.5pts).
I've tried several deviation values in CTrade, but without success, the problem persists.