Eric0

Newbie
Sep 5, 2022
10
6
4
I have contacted the Prop firm I am trading for (Lux Trading) to ask them if they could adjust their scan rate for market orders without a Stoploss.
They can not do this. So all the market orders are immediately deleted by them.
Is there a way to let the EA place these market orders with a Stop Loss? Or maybe give a code snippet, so I can adjust the EA myself?

Cheers, Eric

EDIT:
BTW. I am able to place market orders manually with a stop loss and take profit without errors
 
Last edited:

Eric0

Newbie
Sep 5, 2022
10
6
4
I found and adjusted the needed lines in the 'Position Sizer Trading.mqh' file. Now it is working fine.
I put // in front of lines 285 - 290 and 318 -340
and then re-compile: position sizer.mq4

MQL4:
        //if ((Execution_Mode == SYMBOL_TRADE_EXECUTION_MARKET) && (sets.EntryType == Instant))
        //{
        //    // No SL/TP allowed on instant orders.
        //    order_sl = 0;
        //    order_tp = 0;
        //}

MQL4:
        //if ((Execution_Mode == SYMBOL_TRADE_EXECUTION_MARKET) && (sets.EntryType == Instant) && (ticket != -1) && ((sl != 0) || (tp != 0)))
        //{
        //    if (!OrderSelect(ticket, SELECT_BY_TICKET))
        //    {
        //        Print("Failed to find the order to apply SL/TP.");
        //        isOrderPlacementFailing = true;
        //        break;
        //    }
        //    for (int i = 0; i < 10; i++)
        //    {
        //        if ((tp != 0) && (((tp <= OrderOpenPrice()) && (ot == OP_BUY)) || ((tp >= OrderOpenPrice()) && (ot == OP_SELL)))) tp = 0; // Do not apply TP if it is invald. SL will still be applied.
        //        bool result = OrderModify(ticket, OrderOpenPrice(), sl, tp, OrderExpiration());
        //        if (result)
        //        {
        //            break;
        //        }
        //        else
        //        {
        //            Print("Error modifying the order: ", GetLastError());
        //            isOrderPlacementFailing = true;
        //        }
        //    }
        //}
 
Last edited by a moderator:
  • ℹ️
  • 🎉
Reactions: Enivid and EnrichWave

Enivid

Administrator
Staff member
Nov 30, 2008
18,530
1,355
144
Odesa
www.earnforex.com
I found and adjusted the needed lines in the 'Position Sizer Trading.mqh' file. Now it is working fine.
I put // in front of lines 285 - 290 and 318 -340
and then re-compile: position sizer.mq4

Code:
        //if ((Execution_Mode == SYMBOL_TRADE_EXECUTION_MARKET) && (sets.EntryType == Instant))
        //{
        //    // No SL/TP allowed on instant orders.
        //    order_sl = 0;
        //    order_tp = 0;
        //}

Code:
        //if ((Execution_Mode == SYMBOL_TRADE_EXECUTION_MARKET) && (sets.EntryType == Instant) && (ticket != -1) && ((sl != 0) || (tp != 0)))
        //{
        //    if (!OrderSelect(ticket, SELECT_BY_TICKET))
        //    {
        //        Print("Failed to find the order to apply SL/TP.");
        //        isOrderPlacementFailing = true;
        //        break;
        //    }
        //    for (int i = 0; i < 10; i++)
        //    {
        //        if ((tp != 0) && (((tp <= OrderOpenPrice()) && (ot == OP_BUY)) || ((tp >= OrderOpenPrice()) && (ot == OP_SELL)))) tp = 0; // Do not apply TP if it is invald. SL will still be applied.
        //        bool result = OrderModify(ticket, OrderOpenPrice(), sl, tp, OrderExpiration());
        //        if (result)
        //        {
        //            break;
        //        }
        //        else
        //        {
        //            Print("Error modifying the order: ", GetLastError());
        //            isOrderPlacementFailing = true;
        //        }
        //    }
        //}
And your broker lets you open buy/sell orders with SL/TP with an EA while it has SYMBOL_TRADE_EXECUTION_MARKET set as execution mode? That's weird. My only guess is that they actually have an instant execution mode, but report it as market for some reason to MQL programs.
 

Jakey88

Trader
Sep 6, 2022
22
2
19
35
Hi Enivid, Firstly i would like to say thank for this amazing EA,
It has been working fine since last week when i first got it. For some reason its not working at all Today . It basically freezes and then its stuck on the screen. I have to delete the chart and start again to remove it. Have you any idea why this is happening? im new to metatrader and really not tech minded so apologies for maybe a simple question . Thank You.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,530
1,355
144
Odesa
www.earnforex.com
Hi Enivid, Firstly i would like to say thank for this amazing EA,
It has been working fine since last week when i first got it. For some reason its not working at all Today . It basically freezes and then its stuck on the screen. I have to delete the chart and start again to remove it. Have you any idea why this is happening? im new to metatrader and really not tech minded so apologies for maybe a simple question . Thank You.
What is the output in the Experts tab when it freezes? There should be some kind of an error reported there.
 

Eric0

Newbie
Sep 5, 2022
10
6
4
And your broker lets you open buy/sell orders with SL/TP with an EA while it has SYMBOL_TRADE_EXECUTION_MARKET set as execution mode? That's weird. My only guess is that they actually have an instant execution mode, but report it as market for some reason to MQL programs.
Yeah, I am not completely sure how they do that. What I do know is that the market order is placed and executed (without S/L). But then immediately is closed. So the EA is has practically no time to adjust the order.
The broker the prop firm uses is Global Prime, BTW. I also have a private account with Global Prime. And on that account I have no issues with placing market orders, so it must be the prop firm.
 

EnrichWave

Master Trader
May 15, 2018
325
82
74
India
I found and adjusted the needed lines in the 'Position Sizer Trading.mqh' file. Now it is working fine.
I put // in front of lines 285 - 290 and 318 -340
and then re-compile: position sizer.mq4
Now it place order instantly with SL,TP?. because usually It places orders then it modify the SL,TP.
 

Eric0

Newbie
Sep 5, 2022
10
6
4
Now it place order instantly with SL,TP?. because usually It places orders then it modify the SL,TP.
Yep, when placing a market order it also sends the SL and TP. with the order. (if enabled in in the EA settings)
But check first if your broker supports it by placing a manual trade with SL
 
  • ℹ️
Reactions: EnrichWave

EnrichWave

Master Trader
May 15, 2018
325
82
74
India
I found and adjusted the needed lines in the 'Position Sizer Trading.mqh' file. Now it is working fine.
I put // in front of lines 285 - 290 and 318 -340
and then re-compile: position sizer.mq4
Could you please tell me change it for MT5?.
 

EnrichWave

Master Trader
May 15, 2018
325
82
74
India
Dear @Enivid . If you can make option to enable disable place orders (Including pending) Directly with SL,TP it will be more helpful. So, If some broker didn't allow to place order directly they can use that option to disable Direct Trade with SL,TP.
 

Eric0

Newbie
Sep 5, 2022
10
6
4
Could you please tell me change it for MT5?.
It is basically the same as for MT4. Search for SYMBOL_TRADE_EXECUTION_MARKET, sort out the brackets and put // in front of the relevant lines.

Maybe it is better if the guys who made this great tool would be so kind to add a boolean option to the inputs, so it is possible to switch this option ON/OFF. This way you don't have to adjust the code with every new version.
 

Jakey88

Trader
Sep 6, 2022
22
2
19
35
What is the output in the Experts tab when it freezes? There should be some kind of an error reported there.
Hi,
Here is another screen shot from just now . Its very starnge because it has been working for a little while .
https://charts.mql5.com/33/743/gbpaud-m1-pepperstone-markets-limited-l.png
https://charts.mql5.com/33/743/gbpaud-m1-pepperstone-markets-limited.png
What is the output in the Experts tab when it freezes? There should be some kind of an error reported there.
 

EnrichWave

Master Trader
May 15, 2018
325
82
74
India
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,530
1,355
144
Odesa
www.earnforex.com

Enivid

Administrator
Staff member
Nov 30, 2008
18,530
1,355
144
Odesa
www.earnforex.com