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

EA for adding limit-orders
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5474
Page 1 of 3
Author:  Gertje [ Wed May 30, 2018 8:27 pm ]
Post subject:  EA for adding limit-orders

This is not a request, but just a query whether it is conceived possible.

I’m thinking about a multipair EA, that checks the history and as soon as a trade is closed in profit, and once the pair in question still has open orders, it replaces that EXACT same order as a limit-order.

If there are other limitorders in place, they should be removed (or changed to the new numbers).

So if for example EURUSD closes a sell 1,2345 @ TP 1,2300, it enters a pending limit-sell @1,2345 with 1,2300 TP.

That’s all it should do, just replacing closed orders as long as there are other orders running.
My idea is to re-enter on a pullback, in the direction of price movement.
I’m doing it manually now, with succes, but need to check the charts often.

Update(s):
04-Jun-2018: Added (final) code to Post 1 (this post):
Author:  JonCodesBad [ Wed May 30, 2018 10:24 pm ]
Post subject:  EA for adding limit-orders

Gertje » Wed May 30, 2018 9:27 pm wrote:This is not a request, but just a query whether it is conceived possible.
Yep, fairly straightforward to code.

:rocket:
Author:  renexxxx [ Thu May 31, 2018 3:36 am ]
Post subject:  EA for adding limit-orders

JonCodesBad » Thu May 31, 2018 8:24 am wrote: Yep, fairly straightforward to code.
I like this statement! This is the same as when you ask someone if they know what time it is and you get the answer "Yes".

Anyway, Jon was right. It was fairly straightforward and I have attached the code here. Not sure if it works though, as I haven't had the time yet to test it. If it doesn't work, it will "fairly straightforward" to make it work.

Just run this EA on any chart. You can make it watch any magic number by setting the MagicNumber to -1 (the default). Otherwise, set MagicNumber to the magic number you want it monitor. It will keep track of all open trades with that magic number and will instantly discover if one of them has been closed. If so, it checks if it was closed in profit, remove the other pending trades for the same symbol in the same direction and send a new limit order for the same symbol in the same direction.

Code is in Post 1 of this thread.

Have fun.
Author:  Gertje [ Thu May 31, 2018 8:50 am ]
Post subject:  EA for adding limit-orders

renexxxx » Thu May 31, 2018 3:36 am wrote:
JonCodesBad » Thu May 31, 2018 8:24 am wrote: Yep, fairly straightforward to code.
I like this statement! This is the same as when you ask someone if they know what time it is and you get the answer "Yes".
I guess that was my fault, I asked whether it would be possible at all, and got what I asked for. :smile:
Anyway, Jon was right. It was fairly straightforward and I have attached the code here. Not sure if it works though, as I haven't had the time yet to test it. If it doesn't work, it will "fairly straightforward" to make it work.

Just run this EA on any chart. You can make it watch any magic number by setting the MagicNumber to -1 (the default). Otherwise, set MagicNumber to the magic number you want it monitor. It will keep track of all open trades with that magic number and will instantly discover if one of them has been closed. If so, it checks if it was closed in profit, remove the other pending trades for the same symbol in the same direction and send a new limit order for the same symbol in the same direction.

Have fun.
Thanks a lot Rene, I appreciate your involvement.
I downloaded the EA and tried it on demo, it seems it has a love for AUDJPY.
When I close orders in profit, it re-opens AUDJPY pendings [see below pictures].
The EA is on EURGBP, so that can't be the culprit.

If and when you have the time, would you look into it?
Thanks again,

Gertjan
NZDJPY.png
AUDUSD.png
Author:  renexxxx [ Thu May 31, 2018 9:39 am ]
Post subject:  EA for adding limit-orders

Gertje » Thu May 31, 2018 6:50 pm wrote: I downloaded the EA and tried it on demo, it seems it has a love for AUDJPY.
Ok, I see what's going on: cursor got overwritten. I should test things before posting them.

Code is in Post 1 of this thread.
Author:  Gertje [ Thu May 31, 2018 9:56 am ]
Post subject:  EA for adding limit-orders

renexxxx » Thu May 31, 2018 9:39 am wrote:
Gertje » Thu May 31, 2018 6:50 pm wrote: I downloaded the EA and tried it on demo, it seems it has a love for AUDJPY.
Ok, I see what's going on: cursor got overwritten. I should test things before posting them.

Try now with the attached version.
Was already printing statements when you edited your message. :smile:

New version works fine on several pairs, thank you.
Deleting of old limits didn't always function, ran out of open orders in profit to test more.
I will let it run and keep you posted.

Thanks a lot!
Author:  Gertje [ Thu May 31, 2018 12:51 pm ]
Post subject:  EA for adding limit-orders

:!!:
It works in real time as well!
Global Prime - Empty4 4.png
Now to get rid of these trade comments...... :arrrg:

:smile:
Author:  JonCodesBad [ Thu May 31, 2018 5:20 pm ]
Post subject:  EA for adding limit-orders

Glad my response was taken in the spirit it was meant. It answered the OP & made me chuckle.

Anyhows, on my way home from work I was pondering this idea. I gather Gertje's request was to aid in trading POS.

Would it make sense to limit the number of times a trade is replaced? For example in a triple top situation would you want to be replacing a 4th or 5th time.
Gertje would have the best idea if this would reduce DD, or impede profits to varying degrees.
Author:  renexxxx [ Thu May 31, 2018 7:08 pm ]
Post subject:  EA for adding limit-orders

Gertje » Thu May 31, 2018 10:51 pm wrote: Now to get rid of these trade comments...... :arrrg:
You want to get rid of these "[tp]"'s?

Code is in Post 1 of this thread.
Author:  Gertje [ Thu May 31, 2018 8:10 pm ]
Post subject:  EA for adding limit-orders

JonCodesBad » Thu May 31, 2018 5:20 pm wrote:Glad my response was taken in the spirit it was meant. It answered the OP & made me chuckle.

Anyhows, on my way home from work I was pondering this idea. I gather Gertje's request was to aid in trading POS.

Would it make sense to limit the number of times a trade is replaced? For example in a triple top situation would you want to be replacing a 4th or 5th time.
Gertje would have the best idea if this would reduce DD, or impede profits to varying degrees.
A triple top is bound to go south, sometime in the future.
Trading PoS on H4, one would have entered somewhere along the line and taken advantage of the ranging.

See below chart, the lines are almost 400 pips apart. I trade this pair with a distance between trades of 100 pips, TP is also 100 pips. I stopped counting how many pips one could have made there using my re-entering method.
0FA959C9-38DD-46A6-B8D7-F798C775F666.jpeg
I think it is worth trying, and so I am.
:!!:
All times are UTC Page 1 of 3