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

Manager for 10.3 trades
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=937
Page 1 of 2
Author:  SteveHopwood [ Tue Nov 06, 2012 4:20 pm ]
Post subject:  Manager for 10.3 trades

The attached management EA arose from this pm from Bob:
nanningbob wrote:Can the ability to move the jumping sl up lets say by 6 pips every 5 pips possible. It would do something like this:
set SL -18

at +5 move SL to -12
at +10 move SL to -6
at +15 move SL to 0
at +20 move SL to +5
and so on until it hits the SL or TP

A second choice would be to stop jumping stop after 5 moves or what ever you want.

Thanks,

Bob
I have not done anything about the second choice yet.
  • This is a multi-pair manager, so it will manage all trades so long as they have the same magic number as in the MagicNumber input.
  • JumpIncrementPips is the size of jump required to trigger an sl move.
  • NegativeIncrementPips are the number of pips to jump the stop whilst it is still a negative stop loss i.e. < order open price for a buy, > order open price for a sell.
  • PositiveIncrementPips are the number of pips to jump the stop once it has reached breakeven or above.
  • AlwaysOn sends the bot into an endless loop, going through its calculations twice a second. It will start immediately you load it up, so the chart is irrelevant. You only need one instance of the ea running, unless you want to manage trades with different magic numbers.
I cannot use the normal method of keeping track of when to move the stop loss and I needed a way of telling the ea where it was after a restart. For this I have used Global Variables to store the price the market must reach to trigger the next jump. Press F3 to view the GV window. The ea checks to see if a trade has closed every 15 minutes and deletes redundant GV's.

GV's are not foolproof. They are tiny files stored on you hard drive and so are as subject to corruption as are any other stored files. If any of you maths geeks can come up with a formula that allows the ea to know where it is in the jump process on a restart, then that would be better.

Use the ea to manage manual 10.3 trades and those sent by Gimme Your Hair.

:D

Matters of general interest
Go here to download and run the script that will fill your platform's missing chart history: http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=254
Read this post:
http://www.stevehopwoodforex.com/phpBB3 ... p?f=6&t=78 Newbie traders, read this for inspiration and warning. Those of you who have suffered losses, read it for inspiration.

Masterly summary of hedging: http://www.forexfactory.com/showthread. ... ost4977179

EA coding
I receive may requests to code EA's. Traders, if I code your EA for free, then I will share it here. If you want me to code your EA without sharing, then my fee is $100 payable into my paypal account. I explain why at http://www.stevehopwoodforex.com/phpBB3 ... ?f=15&t=79, at the bottom of the post.

Useful utilities/EA's/scripts
Author:  alex_forex [ Tue Nov 06, 2012 4:37 pm ]
Post subject:  Re: Manager for 10.3 trades

Must solve my SL errors because of the tight stops !

Thanks Steve :D
Author:  gaheitman [ Tue Nov 06, 2012 4:48 pm ]
Post subject:  Re: Manager for 10.3 trades

Nice! For years I've wanted a trailing stop variant that would catch up to price, but was never motivated enough to do anything about it...

As for the math, I believe you need to know the initial SL to determine where you are in the jump sequence. Since they won't always be the same, we'd have to do something to store the starting SL. I know, we could use a GV! :D

George
Author:  bshoe24 [ Tue Nov 06, 2012 5:45 pm ]
Post subject:  Re: Manager for 10.3 trades

This sounds similar to the ATM (automated trade management) of Ninjatrader which works nicely for jumping SL. Thanks Steve.
Author:  SteveHopwood [ Tue Nov 06, 2012 9:41 pm ]
Post subject:  Re: Manager for 10.3 trades

When I loaded the manager onto my 10.3 Scalper demo, I noticed I had left some doubles viewable to users. Altering their values in the inputs window will have no effect. If their presence bothers you, then redownload - I have removed them from sight.

:D
Author:  nanningbob [ Tue Nov 06, 2012 10:19 pm ]
Post subject:  Re: Manager for 10.3 trades

Thanks Steve, I will get to this after school today.
Author:  POH [ Wed Nov 07, 2012 4:38 am ]
Post subject:  Re: Manager for 10.3 trades

Does this set an initial SL?
Author:  fxozgirl [ Wed Nov 07, 2012 6:30 am ]
Post subject:  Re: Manager for 10.3 trades

POH wrote:Does this set an initial SL?

No, you set you're own SL, then the EA manages the trade from there.
Author:  fxozgirl [ Wed Nov 07, 2012 6:36 am ]
Post subject:  Re: Manager for 10.3 trades

Steve, I've set this up and it looks like it is working well OOTB with some adjustments to SL already occurring correctly :D

One thing I have noticed is I've set up some pending trades and attached the EA in anticipation, however it appears to be trying to modify the trade and returning a 'trade context is busy' error for the pending trades.

Not causing any problems with actual trades, just an FYI as the error is filling up the logs.


Hmmm...just had a thought, I haven't set a magic number for any of the charts...would that be causing the error?

2012.11.07 17:28:02 Bob's 10.3 trade management EA USDJPY,M15: Bob's 10.3 trade management EA 45586675 TradeManagementModule stop loss modification failed with error 146: trade context is busy
Author:  gaheitman [ Wed Nov 07, 2012 7:59 am ]
Post subject:  Re: Manager for 10.3 trades

fxozgirl wrote:Steve, I've set this up and it looks like it is working well OOTB with some adjustments to SL already occurring correctly :D

One thing I have noticed is I've set up some pending trades and attached the EA in anticipation, however it appears to be trying to modify the trade and returning a 'trade context is busy' error for the pending trades.

Not causing any problems with actual trades, just an FYI as the error is filling up the logs.


Hmmm...just had a thought, I haven't set a magic number for any of the charts...would that be causing the error?

2012.11.07 17:28:02 Bob's 10.3 trade management EA USDJPY,M15: Bob's 10.3 trade management EA 45586675 TradeManagementModule stop loss modification failed with error 146: trade context is busy
The code only manages trades with a matching MagicNumber (the default is 0) that are in profit. I wouldn't think a pending order would have a profit, but I don't know that I've ever called OrderProfit() to see. :)

You are just running it on one chart, right?

Steve should probably add the standard "while trade context busy" check prior to the OrderModify() function to make sure this doesn't happen.

George
All times are UTC Page 1 of 2