MPTM's new home

MPTM's new home
Locked
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

MPTM's new home

Post by SteveHopwood »

Welcome to MPTM. MPTM was the first EA I offered up for use by fellow traders. I am astonished to find it being used all over the world. I originally made it available at Forex Factory, but the dimwit that runs the forum has pissed me off, so I have moved it here.

For those of you who do not know what mtpm is: I have written/am writing a multi-purpose trade managing EA. At heart, this is about manipulating stop losses and take profits of trades already open. The only way to get a feel for what the ea does is to read the user guide and try the ea on demo, using what you glean from the guide to help you select your input values.

I posted the first version of mptm back in the summer of 2008. Since then, it has grown and grown. I hope you find it useful.

Disclaimer
I coded a lot of functions into the ea in response to requests from users to do so. I have not used many of them and have forgotten how they work or what they do. Do not bother asking me questions such as, "What do I do to......", or, "How do I....." The chances are that I do not know the answer. In any case, I shall ignore the question. Read the user guide and experiment on demo to find a solution. Feel free to ask questions of other traders here. Someone might know the answer and be prepared to supply an answer; just don't expect one from me. Don't waste time sending me pm's about problems either; I shall ignore them. Well, I shall ignore them on a good day. On a bad day, just remember that I am a power-crazed admin. :lol:

Doing thingies for yourselves
Whenever using an ea, script or indicator, it helps enormously if we traders can customise the inputs to suit ourselves. "How to edit a script code" describes how to do this; the lessons learned are equally applicable to any Empty4 software. Read the pdf and learn how to make these basic edits for yourselves; it is both useful and fun to be able to do so. Go on, go for it. You know you can. You know you want to........................ :lol:

A couple of useful pending order scripts presented by DragosDanescu: http://www.stevehopwoodforex.com/phpBB3 ... p=831#p831

Updates not included in the user guide
Trade management hours. This feature works the same way as does trading hours in my trading EA's, so find one of the umpteen copies of the Shell user guide for details. The reason for this addition is to be found at http://www.stevehopwoodforex.com/phpBB3 ... 9080#p9080

Pips/points conversion
All pips entries should be made in proper pips, not the dreadful points thingy foisted upon us by the market-maker crims determined to confuse us and so separate us from our deposits.

For this, all our thanks go to Lifesys - Paul. Paul has adapted all the previous pips/point stuff that emerged a while ago. He has also adapted the part-close code to simply close Close_LotsFract percent of a trade at each closure point, so no need any more to specify Close_Lots and Preserve_Lots. Thanks Paul. You are a star.

For the coders
There are two multi-purpose functions to deal with the usual OrderModify(), OrderDelete() and OrderClose() functions:
  • bool ModifyOrder(int ticket, double price, double stop, double take, datetime expiration, color col, string function, string reason)
  • bool CloseOrder(int ticket, string function, double CloseLots, string reason)
There is a single error reporting function - void ReportError(string function, string message) - that is called from within ModifyOrder() and CloseOrder(). So, instead of all those OrderClose(list of params) calls with all those error call functions when something goes wrong, we have a simple one line call.

For example, CloseBasketTrades() has this call:

Code: Select all

bool result = CloseOrder(OrderTicket(), __FUNCTION__,  OrderLots(), ocm );
__FUNCTION__ is a useful thingy that I found. It is two underscores on either side of the word. It holds the name of the function from which CloseOrder() is called. 'ocm' is the 'reason' parameter and stands for 'Order Close Message'. The CloseOrder() function sends 'reason' to ReportError() if the trade closure fails. There is a list of defined constants at the top of the code. You can add to them yourself, and you can pass 'reason' as a string. Suppose you wanted to close half the trade:

Code: Select all

bool result = CloseOrder(OrderTicket(), __FUNCTION__,  OrderLots() / 2, "Closing half the trade" );
CloseOrder() also deletes pending trades, so this might need modifying, depending on what you are trying to achieve.

Example of ModifyOrder() for moving the stop loss:

Code: Select all

result = ModifyOrder(OrderTicket(), OrderOpenPrice(), stop, OrderTakeProfit(), OrderExpiration(), clrNONE, __FUNCTION__, slm);
Bear all this in mind when adding your own custom functions; it will make your life easier.

MPBM
There are basket management features in MPTM, but Baluda has created a dedicated Multi-Purpose Basket Manager. Find it at http://www.stevehopwoodforex.com/phpBB3 ... 112#p16112

Versions modified by other coders
I have not necessarily tried them or recommend them or know what the mods are. It just seems fair to apprise members that modifications exist. Experiment with them and see if there is something you can use. :D
You do not have the required permissions to view the files attached to this post.
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
currymonster
Trader
Posts: 99
Joined: Wed Nov 16, 2011 8:37 pm

Re: MPTM's new home

Post by currymonster »

Thanks Steve,since moving to my new super computer, have lost lots of my old trading buddies, like MPTM. Want to use it with Jiva BB as I'm not getting any stops or TP set on Cowboy Go Markets, order modify failure errors. So hopefully MPTM will kick some butt!

Cheers
sahars
Trader
Posts: 13
Joined: Wed Nov 16, 2011 1:44 pm

Re: MPTM's new home

Post by sahars »

Thanks Steve... As always you are awesome....

Cheers
DragosDanescu
Trader
Posts: 118
Joined: Wed Nov 16, 2011 5:18 pm
Location: Oradea, Western Romania

Re: MPTM's new home

Post by DragosDanescu »

Some scripts for fast placing of pending orders, including SL, TP, I can customize them in any way possible, just ask.

This pair of scripts have OnWindowDrop function, so they open exactly where you drop them on the chart.
You do not have the required permissions to view the files attached to this post.
Image
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: MPTM's new home

Post by SteveHopwood »

DragosDanescu wrote:Some scripts for fast placing of pending orders, including SL, TP, I can customize them in any way possible, just ask.

This pair of scripts have OnWindowDrop function, so they open exactly where you drop them on the chart.
I have linked this in post 1.

Cheers

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
faxxion
Trader
Posts: 11
Joined: Wed Nov 16, 2011 8:54 pm

Re: MPTM's new home

Post by faxxion »

Hello Steve,

I have a couple of suggestions for MPTM.

First, has to do with order entry. Just below the EA line in the upper right corner of the chart would be 3 buttons - long (blue), short (red) and close (yellow) just like on the Empty4 order entry window. We would have to tell the inputs what the order was for (single pair, basket, etc...). Then that trade could be entered by a simple click from one chart. This would make those trades easily identifiable by Magic Number. This would be especially helpful for basket trading. After that, the selected money management technique chosen would take over.

Second, has to do with another money management option. Can we add Martingale levels and lot multiplier inputs at each level along with an ultimate stop loss / take profit for the entire trade. For example, if I am long the 1 lot EURUSD and it drops X pips, I can tell it to buy 2 more lots now looking for X profit, but both trades would be stopped out at X pips.

I hope I made myself clear. If some of these functions already exist, please advise. If you have any questions, you have my private email.

Thanks,

William
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: MPTM's new home

Post by SteveHopwood »

faxxion wrote:Hello Steve,

I have a couple of suggestions for MPTM.

First, has to do with order entry. Just below the EA line in the upper right corner of the chart would be 3 buttons - long (blue), short (red) and close (yellow) just like on the Empty4 order entry window. We would have to tell the inputs what the order was for (single pair, basket, etc...). Then that trade could be entered by a simple click from one chart. This would make those trades easily identifiable by Magic Number. This would be especially helpful for basket trading. After that, the selected money management technique chosen would take over.

Second, has to do with another money management option. Can we add Martingale levels and lot multiplier inputs at each level along with an ultimate stop loss / take profit for the entire trade. For example, if I am long the 1 lot EURUSD and it drops X pips, I can tell it to buy 2 more lots now looking for X profit, but both trades would be stopped out at X pips.

I hope I made myself clear. If some of these functions already exist, please advise. If you have any questions, you have my private email.

Thanks,

William
I might look at this at some stage, but shudder to think of the potential for LUC inviting the entire universe on a bender that would make the Vesuvius eruption look like a hiccough.

So, not yet. Sorry.

Anyone else is welcome to have a go, folks. Although mptm bears my name, there are actually many contributors.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
oenomaus
Posts: 1
Joined: Wed Nov 16, 2011 2:35 pm

Re: MPTM's new home

Post by oenomaus »

Hello,

I have a problem with MPTM. The broker I use (Trading Point) use different digits for different currencies, some currencies are 4 digits(10$/point for 1lot) and some are 5 digits(1$/point for 1lot). So, when I place the MPTM on a 5 digit chart it calculates the BreakEven(set as 30pips) pips as 300 points which is correct but manages 4digit pairs with same value which equals to 300pips for that currency. The workaround I use is to find the 4digits and 5digits pairs and setup two MPTM for each set, one placed on a 4digit pair and the other onto a 5digit pair.

Is there a way to make MPTM detect this difference automatically? I did not see anything on the manual about this issue.

Thank you.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: MPTM's new home

Post by gaheitman »

The way most of the EAs work is to allow you to enter your inputs as Pips, and then in the initialization of the program it converts all these to match the underlying currency's number of digits. As you've pointed out, this doesn't work when managing different currencies (with different digits) from the same chart.

Unfortunately, since it is in the initialization section there is no quick fix.

On the plus side, I now know why one of my scripts is failing on Yen pairs. :D When I fix that script, I will try to keep the issue in mind and come up with a generic solution.

George
oenomaus wrote:Hello,

I have a problem with MPTM. The broker I use (Trading Point) use different digits for different currencies, some currencies are 4 digits(10$/point for 1lot) and some are 5 digits(1$/point for 1lot). So, when I place the MPTM on a 5 digit chart it calculates the BreakEven(set as 30pips) pips as 300 points which is correct but manages 4digit pairs with same value which equals to 300pips for that currency. The workaround I use is to find the 4digits and 5digits pairs and setup two MPTM for each set, one placed on a 4digit pair and the other onto a 5digit pair.

Is there a way to make MPTM detect this difference automatically? I did not see anything on the manual about this issue.

Thank you.
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: MPTM's new home

Post by SteveHopwood »

oenomaus wrote:Hello,

I have a problem with MPTM. The broker I use (Trading Point) use different digits for different currencies, some currencies are 4 digits(10$/point for 1lot) and some are 5 digits(1$/point for 1lot). So, when I place the MPTM on a 5 digit chart it calculates the BreakEven(set as 30pips) pips as 300 points which is correct but manages 4digit pairs with same value which equals to 300pips for that currency. The workaround I use is to find the 4digits and 5digits pairs and setup two MPTM for each set, one placed on a 4digit pair and the other onto a 5digit pair.

Is there a way to make MPTM detect this difference automatically? I did not see anything on the manual about this issue.

Thank you.
I first coded mptm in the good ole days when all quotes were 2/4. The crims introduced 3/5 digit quotes deliberately to try to confuse everyone. Once we are used to 3/5 quotes, they will introduce 6/8. There is no limit on this until we traders dig our heels in and stop them.

Having said that, mptm always had to differentiate between different Bid, Ask, Point and Digit values. I overcame this by setting up variables that have the same name but without the capital letter. They are bid, ask, point, digit. (Shut up George. I did this deliberately so I know which variables I was addressing each time, and have no problem remembering to leave off the leading cap, ok? :lol: )

Therefore, mptm already addresses automatically the different Digit sizes, up to 5. If your crim has come up with a way of pissing around with all this by, for example, variable Digits from quote to quote (doubtless the next trick these bastards will come up with to 'help our valued clients make the most of their incomparable trading experience') then some of the mptm code might be rendered useless. I don't care. If the crims piss you around, then find one that does so a little less.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Locked

Return to “Utilities Indicators and Scripts”