Is "GBPUSDme" the name of the financial instrument that you want to trade?
tebbsy96: "failed market
sell 0.03 GBPUSDme sl:1.40524 tp:1.40024 [invalid request]. Not sure why, … Any tips would be appreciated.
Your code bool IsNewBar=false; if(Old_Time!=New_Time[0]) { IsNewBar=true; }
Simplified bool IsNewBar=Old_Time!=New_Time[0];
- Old_Time is never updated.
Your code bool Bullish_Pin_Bar=false; if(p_close>p_open) { if(p_close-p_open<0.25*(p_high-p_low)) { if(p_open>p_low+(0.75*(p_high-p_low))) Bullish_Pin_Bar=true; } }
Simplified double range=p_high-p_low; bool Bullish_Pin_Bar= p_close>p_open // Redundent test ⋙⋙ && p_close-p_open < 0.25*range && p_open>p_low + 0.75*range;
-
mrequest.action=TRADE_ACTION_DEAL; mrequest.price=NormalizeDouble(latest_price.ask,_Digits); mrequest.sl=NormalizeDouble(latest_price.ask-StopLoss*_Point,_Digits); mrequest.tp=NormalizeDouble(latest_price.ask+TakeProfit*_Point,_Digits); mrequest.symbol=_Symbol; mrequest.volume=NormalizeDouble(Lotsize,_Digits); mrequest.magic=EA_Magic; mrequest.type=ORDER_TYPE_BUY; mrequest.type_filling=ORDER_FILLING_FOK; mrequest.deviation=50; OrderSend(mrequest,mresult); //--send order
Don't copy and paste code. You have 8 of these; are they all correct? Make them a function and you only need to check once. - You buy at the Ask and sell at the Bid.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice
reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools →
Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
-
PositionGetDouble(POSITION_PRICE_OPEN);
What do you think that does?
WindmillMQL:
Yes it is.
Is "GBPUSDme" the name of the financial instrument that you want to trade?
William Roeder:
Your code Simplified - Old_Time is never updated.
Your code Simplified - Don't copy and paste code. You have 8 of these; are they all correct? Make them a function and you only need to check once.
- You buy at the Ask and sell at the Bid.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice
reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools →
Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
- What do you think that does?
Yeah i'll look into changing the SL and TP, thanks for the advice.
Regarding point 6, I thought that function would return the the opening price of an open position?
William Roeder:
Also, regarding point 4, I had the the wrong filling type. Thats sorted now so it is placing orders but its not placing them at the right time,
something must be wrong with my entry conditions.
Your code Simplified - Old_Time is never updated.
Your code Simplified - Don't copy and paste code. You have 8 of these; are they all correct? Make them a function and you only need to check once.
- You buy at the Ask and sell at the Bid.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice
reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools →
Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
- What do you think that does?
tebbsy96:
Yes it is.
I was asking this because the error message you received is "invalid request". This could mean that the name of the symbol is incorrect, or that any of the prices you submitted are not valid.
Yes it is.

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
My EA won't place any trades when I backtest it, just comes up with "failed market sell 0.03 GBPUSDme sl:1.40524 tp:1.40024 [invalid request]. Not sure why, it should open a buy trade when the 1H 50 EMA is above the 1H 200 EMA, the 15M 50 EMA is above the 15M 200 EMA, when there is a bullish engulfing candle or bullish pin bar, when the price is below the 5M 50 EMA and should only open a position if there are no open buy trades or if the price is below the opening price of any currently open buy trades. For sell trades, all of this should just be reversed. Been going through my code for a while but I can't see why this is happening. Any tips would be appreciated.
Thanks