Enivid

Administrator
Staff member
Nov 30, 2008
19,127
1,487
144
Odesa
www.earnforex.com
hello y have a problem in the compilate there is not error but no works, is not open in metatrader 4
Sorry, it's not clear - does it compile without errors? If so, what happens when you are trying to add it to a chart in your MetaTrader 4? What does it say in the Experts tab log? Also, what build of MT4 are you using? You can check it via the menu Help->About...
 

Jakey88

Trader
Sep 6, 2022
27
2
19
35
Hello @Enivid . Loving the latest version, very grateful thank You .
I have a suggestion maybe You would consider for the future . Adding Hotkeys for the quick risk in the Trading tab. For scaling into set ups without the need to open the Tab.
Thanks again .
 

yoovie

Trader
Feb 9, 2022
19
21
14
Yes, that happens in MT5. I have no idea how to fixed it.
I think this happens because there are codes that set the textfield value in OnTick or OnTimer functions. And not just Position Size textfield that's affected, the SL and TP textfields are also affected.

Another issue in the MT5 version is the unselected TP line issue when the line is shown first time by clicking Take-Profit button that still exists.
 

T0BIAS

Newbie
Sep 24, 2024
2
0
1
30
Can anyone explain how I can enable the breakeven line?

Does this only works if I put in a value in the breakeven field?

Because I was looking for something that will set auto breakeven when price reaches a certain price or risk reward.
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
19,127
1,487
144
Odesa
www.earnforex.com
Can anyone explain how I can enable the breakeven line?
If you set some value in the BE field and set some color for the BE line via input parameters, the BE line will appear on the chart.

Does this only works if I put in a value in the breakeven field?
Yes, it won't work without that.
Because I was looking for something that will set auto breakeven when price reaches a certain price or risk reward.
You still need to put the respective value in points in the BE field.
 
  • 👍
Reactions: T0BIAS

Enivid

Administrator
Staff member
Nov 30, 2008
19,127
1,487
144
Odesa
www.earnforex.com
I think this happens because there are codes that set the textfield value in OnTick or OnTimer functions. And not just Position Size textfield that's affected, the SL and TP textfields are also affected.
Perhaps, yes, perhaps, no. Why would it succeed sometimes if that was the reason? And if that is the reason, how can it be avoided? I don't know. I will gladly accept any ideas.
Another issue in the MT5 version is the unselected TP line issue when the line is shown first time by clicking Take-Profit button that still exists.
This too is another mystery for me. The line gets unselected upon calling a standard library function that has nothing to do with lines. This can be potentially circumvented, but since the origin of the issue is unclear, the circumvention may just stop working. If you have some details on this bug, I will be very interest to know them.
 

Enivid

Administrator
Staff member
Nov 30, 2008
19,127
1,487
144
Odesa
www.earnforex.com
Regarding the unselected TP line issue in MT5 version, I traced down the code and found out this line that caused the issue: https://github.com/EarnForex/PositionSizer/blob/3.09/MQL5/Experts/Position Sizer/Position Sizer.mqh#L2455

The code inside HideShowMaximize method (which is called in ProcessTPChange method) somehow reverts the property OBJPROP_SELECTED of "TakeProfitLine" line object to false.
Sorry, I didn't notice this post when posted my first reply to you. Thanks for the suggestion, but I already tracked it down to the standard library's CWndContainer::Hide call. It has nothing to do with lines, but it still gets the TP line unselected. As I have said, I can circumvent this with a very rough workaround, but this can be some serious problem that will be manifesting itself differently.
 

yoovie

Trader
Feb 9, 2022
19
21
14
Perhaps, yes, perhaps, no. Why would it succeed sometimes if that was the reason? And if that is the reason, how can it be avoided? I don't know. I will gladly accept any ideas.
I haven't really checked your code to confirm whether the OnTick function has logic of updating the Position Size textfield value or not, I just assumed so since I faced the same issue when I was developing my MT5 version of MQLTA OCTP, if I put updating textfield value logic in OnTick function, the same issue would happen. I'm guessing this might be a bug in MT5 platform, maybe there is a conflict issue between ObjectSetString and CHARTEVENT_OBJECT_ENDEDIT event when they happen in same time. I don't really have an idea for the solution other than don't put updating value of user-editable-textfield logic in OnTick function (if you really put the logic there).

Sorry, I didn't notice this post when posted my first reply to you. Thanks for the suggestion, but I already tracked it down to the standard library's CWndContainer::Hide call. It has nothing to do with lines, but it still gets the TP line unselected.
Yeah, I'm aware it's the Hide function, this might be a bug in MT5 Panel library as it doesn't happen in MT4.
As I have said, I can circumvent this with a very rough workaround, but this can be some serious problem that will be manifesting itself differently.
I see, that's unfortunate since this bug is quite annoying.
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
19,127
1,487
144
Odesa
www.earnforex.com
Enivid,

I'm having an issue with changing the position size on pending orders.

Sometimes it takes a few attempts before it changes.

View attachment 29597
I haven't really checked your code to confirm whether the OnTick function has logic of updating the Position Size textfield value or not, I just assumed so since I faced the same issue when I was developing my MT5 version of MQLTA OCTP, if I put updating textfield value logic in OnTick function, the same issue would happen. I'm guessing this might be a bug in MT5 platform, maybe there is a conflict issue between ObjectSetString and CHARTEVENT_OBJECT_ENDEDIT event when they happen in same time. I don't really have an idea for the solution other than don't put updating value of user-editable-textfield logic in OnTick function (if you really put the logic there).
Please try the attached beta version. I've tried to fix this (once again) and I'm not sure how reliable this fix is.
 

Attachments

  • Position Sizer.ex5
    537.2 KB · Views: 0