stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

MPTM_Global
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1633
Page 2 of 14
Author:  SteveHopwood [ Sat Jan 19, 2013 10:58 pm ]
Post subject:  Re: MPTM's new home

global wrote:
SteveHopwood wrote:If, say, StopLoss is declared as an integer as in int StopLoss = 20:
double NewStop = NewStop = OrderOpenPrice() - (StopLoss * Point); is allowed and (StopLoss * Point) creates a 0.xxxxxxxx result.

The command using factor is OrderOpenPrice() - (StopLoss / factor); But, if StopLoss is an integer then the code (StopLoss / factor) returns a zero value.

All the pip values in mptm were declared as integers, so when interacting with factor resulted in 0 being added to whatever the bot was supposed to be doing, and so trades were closing prematurely. All that was needed was to convert them to doubles - something Paul forgot to do and that I did not notice.

So, fix is in post 1; sing out if I am barking at the wrong moon and the fix does not work.
:D
Thanks for the update Steve. I checked your updated code and I'm wondering if the int iPipsAboveVisual variable in line 901 needs to be converted to double iPipsAboveVisual from this line of code...

Code: Select all

bool CheckForHiddenStopLossHit(int type, int iPipsAboveVisual, double stop )
...because a little further down you divide iPipsAboveVisual by Pipfactor as below:

Code: Select all

double sl = NormalizeDouble(stop + (iPipsAboveVisual /Pipfactor), digits);
Nice one global and seems likely you are correct. Even if not, I have made the change and updated the post 1 version.

I tamper with mptm's code with the greatest reluctance. The Steve who started coding it back in about 2007 and the Steve who codes these days are completely different coding individuals. Had I understood even a fraction back then of what I understand now, the code would be completely different. Anybody updating my code now has the me back from 2007 to contend with, and does so at the peril of the entire EA. I shall probably ignore well-intentioned updates in the future.

Added to my early inexperience is the fact that mptm's code has been expanded by several contributors over the years. I rarely have any idea what they were doing and just go with the flow. mptm is ridiculously complex and we are left this this unavoidable truth: tampering with mptm code invites LUC (Law of Unintended Consequences) to throw the bender of the decade for his buddies. What has happened here is a great example.

:D
Author:  global [ Sat Jan 19, 2013 11:05 pm ]
Post subject:  Re: MPTM's new home

Mike wrote:Thanks ... clear explanation. What I did: save and compile a version each for D1, H4, H1 by opening the meta editor using Find 1440 Replace all by 240 for H4/ Replace all by 60 for H1. I hope I did not mess up anything.
What I also would like to do is to eliminate all options in the Custom Indicator window, which I do not intend to use for this kind of trade management, but I do not know how (Example):
extern bool ManageByMagicNumber=false;
change to
bool ManageByMagicNumber=false;
but I actuall have no idea what I am really doing.
Thanks again for your modifications and explanations
Mike
The replace all you did seems fine and yes you can just replace extern bool with bool to remove the options you do not use but make sure that you save a copy of the original EA so that you can remember for which options you removed the extern. Or you can add a comment at the end of every option line you changed like this:

bool ManageByMagicNumber=false; //removed extern variable from input
Author:  global [ Sun Jan 20, 2013 2:18 am ]
Post subject:  Re: MPTM's new home

On Monday when I'll have a chance to test it first, I'll upload my fixed version of MPTM AdMod with all the pip inputs changed from int to double.
Author:  cuzgeorge [ Sun Jan 20, 2013 7:17 am ]
Post subject:  Re: MPTM's new home

Great work Global,
and thank you Steve and Mike for the inputs.
I'm a huge user of MPTM and would'nt leave home with-out it. Any help like this is really appreciated from non-coders like me.
regards,
cuz
Author:  Mike [ Sun Jan 20, 2013 9:14 am ]
Post subject:  Re: MPTM's new home

global wrote:
Mike wrote:Thanks ... clear explanation. What I did: save and compile a version each for D1, H4, H1 by opening the meta editor using Find 1440 Replace all by 240 for H4/ Replace all by 60 for H1. I hope I did not mess up anything.
What I also would like to do is to eliminate all options in the Custom Indicator window, which I do not intend to use for this kind of trade management, but I do not know how (Example):
extern bool ManageByMagicNumber=false;
change to
bool ManageByMagicNumber=false;
but I actuall have no idea what I am really doing.
Thanks again for your modifications and explanations
Mike
The replace all you did seems fine and yes you can just replace extern bool with bool to remove the options you do not use but make sure that you save a copy of the original EA so that you can remember for which options you removed the extern. Or you can add a comment at the end of every option line you changed like this:

bool ManageByMagicNumber=false; //removed extern variable from input
Thanks, really, really helpful. I'll wait for your updated version, will do the modifications I plan (following your suggestion of commenting and keeping an original code untouched) and submit them for general use.
Mike
Author:  global [ Tue Jan 22, 2013 9:46 pm ]
Post subject:  Re: MPTM's new home

UPDATE Jan 22nd, 2013 of Multi purpose trade managerADMod_D1: For all pips values in the code that were declared as integers, I re-declared them as decimal "double" data types because Steve discovered an Empty4 program anomaly with how it calculates a mixture of int and double data type variables in certain circumstances. I tested it and everything seems fine so I replaced the attached file in the original post with the updated one here: http://www.stevehopwoodforex.com/phpBB3 ... 816#p34816
Author:  SteveHopwood [ Tue Jan 22, 2013 11:04 pm ]
Post subject:  Re: MPTM's new home

global wrote:UPDATE Jan 22nd, 2013 of Multi purpose trade managerADMod_D1: For all pips values in the code that were declared as integers, I re-declared them as decimal "double" data types because Steve discovered an Empty4 program anomaly with how it calculates a mixture of int and double data type variables in certain circumstances. I tested it and everything seems fine so I replaced the attached file in the original post with the updated one here: http://www.stevehopwoodforex.com/phpBB3 ... 816#p34816
Thanks for all this, global. I have linked your version in post 1. It will help me a lot if you issue further updates in the linked post so I do not have to keep updating. If there is ever a problem doing so, let me know and I will sort it out - being Admin allows me to play God like this. :lol:

:D
Author:  global [ Thu Jan 24, 2013 3:27 pm ]
Post subject:  Re: MPTM's new home

SteveHopwood wrote:Thanks for all this, global. I have linked your version in post 1. It will help me a lot if you issue further updates in the linked post so I do not have to keep updating. If there is ever a problem doing so, let me know and I will sort it out - being Admin allows me to play God like this. :lol:

:D
You are very welcome Steve. You are the one we have to thank for creating MPTM.

No problem, I will post further updates in my original post that you linked to.
Author:  global [ Thu Mar 14, 2013 4:13 am ]
Post subject:  MPTM AdMod version UPDATE

MPTM ADMod version UPDATE, March 13th, 2013: In this update I added a few new features that may make it a little more difficult for you to set up MPTM correctly. Nevertheless, once you read the descriptions of the new features in the EA input dialog box, understand how they all work together and set up MPTM just as you like it, then managing your trades will be as easy as just clicking your mouse.

In this update I added the following options:

1) A Tightening stop option to replace the 4 target levels: TrailAt25%, 50%, 75% & 85% of the Take Profit (TP), with 4 PIP targets. When these PIP targets are hit, your JumpingStopPips or TrailingStopPips will move to the x number of pips you specify.

2) An option to set your TrailingStopPips & JumpingStopPips as percentages of the TP. This overrides the TrailingStopPips & JumpingStopPips values from the Jumpingstoploss & Trailingstoploss settings.

3) An option to set the TrailingStopPips & JumpingStopPips as percentages of the ATR. This overrides the TrailingStopPips & JumpingStopPips values from the Trailingstoploss & Jumpingstoploss settings.

I also changed some of the EA input descriptions a bit to make things a little clearer. The default settings are for setting the Break Even, Trailing/Jumping and Tightening Stops based on percentages of the Take Profit (TP). I'm currently experimenting with those default values but of course you can change the settings as you like and set the Break Even, Trailing/Jumping and Tightening Stops as fixed pips or set them based on percentages of the ATR.

Once your settings are all based on your Take Profit, as in this updated version, you can use the EA with any timeframe since no ATRs are used in the calculations. If you like you can modify the code to hard code your settings and save the EA with a different name such as "MPTM ADMod.mq4" or any name you like without the _D1, _H4, etc suffixes to remind yourself that it can be used with any timeframe without the need to change any settings.

Please go here to download the updated version: http://www.stevehopwoodforex.com/phpBB3 ... 816#p34816
Author:  global [ Fri Mar 15, 2013 9:35 am ]
Post subject:  Re: MPTM's new home

UPDATE March 15th, 2013: Fixed the MPTM ADMod EA screen comment error where the "Trailing stop on and set to xx% ATR: xx pips" was displaying the TrailJumpStopPercentageTP value instead of the TrailJumpStopPercentageATR value.

Note: If you use the Tightening Stop Feature and select UseTrailJumpStopPercentageATR or UseTrailJumpStopPercentageTP as true, then the xx number of pips in the EA screen comment message "Trailing/Jumping stop on and set to xx% ATR: xx pips" or "Trailing/Jumping stop on and set to xx% TP: xx pips" will change as your Trailing or Jumping stops tighten BUT the initial xx% ATR or xx% TP value will remain the same to show the initial Trailing Stop or Jumping Stop % ATR or % TP value you selected.

Please go here to download the updated version: http://www.stevehopwoodforex.com/phpBB3 ... 816#p34816
All times are UTC Page 2 of 14