Eric0

Newbie
Sep 5, 2022
10
6
3
Could you please attach the problematic template here? And the settings file with the input parameters separately?
.tpl and .mq4 files are attached. I have modified the mql4 code for the Position Sizer (I changed Only! the input parameters) so I don't have to load a set file every time.
FYI. Applying this template to a chart shows the correct behavior; eg. no lines visible.
The problem is this:
1. I apply the saved template to a chart.
2. Then change to another profile.
3. Change back to the profile with the chart which has the position sizer EA attached.
Then I see the SL, TP and Entry lines drawn on the chart and the "Show Lines" button is shown on the panel.
Cheers, Eric
 

Attachments

  • PosSiz.tpl
    58.1 KB · Views: 1
  • Position Sizer.mq4
    28.9 KB · Views: 1

Enivid

Administrator
Staff member
Nov 30, 2008
17,135
1,046
144
Odessa
www.earnforex.com
.tpl and .mq4 files are attached. I have modified the mql4 code for the Position Sizer (I changed Only! the input parameters) so I don't have to load a set file every time.
FYI. Applying this template to a chart shows the correct behavior; eg. no lines visible.
The problem is this:
1. I apply the saved template to a chart.
2. Then change to another profile.
3. Change back to the profile with the chart which has the position sizer EA attached.
Then I see the SL, TP and Entry lines drawn on the chart and the "Show Lines" button is shown on the panel.
Cheers, Eric
Looks like a bug with profiles. I will look into it. Thanks for reporting!
 

crocalbtc

Trader
Jan 21, 2020
1
1
14
30
Hi guys, I am following you for long time and I'm very happy that you turned PSC indicator into EA.
Since it can continuously work now as EA, would it be possible to add 2 new options for Trade/Time Management:
1. Close Pending Trades at Server Time:
2. Close Open Trades at Server Time:

Thanks a lot everyone and have a great day.
 
  • 👍
Reactions: EnrichWave

Enivid

Administrator
Staff member
Nov 30, 2008
17,135
1,046
144
Odessa
www.earnforex.com
Hi guys, I am following you for long time and I'm very happy that you turned PSC indicator into EA.
Since it can continuously work now as EA, would it be possible to add 2 new options for Trade/Time Management:
1. Close Pending Trades at Server Time:
2. Close Open Trades at Server Time:

Thanks a lot everyone and have a great day.
That's better attained by using the Account Protector EA.
 

Eric0

Newbie
Sep 5, 2022
10
6
3
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
3
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
17,135
1,046
144
Odessa
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
10
2
8
34
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
17,135
1,046
144
Odessa
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
3
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
196
41
54
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
3
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
196
41
54
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
196
41
54
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
3
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
10
2
8
34
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.