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

Trend Trading EA with Automated Loss Recovery
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3719
Page 8 of 14
Author:  SpiderX [ Fri Jul 18, 2014 10:02 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Rounds up to the next 0.01

Cheers
Author:  Elixe [ Fri Jul 18, 2014 10:03 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Hi Dewey,

Ceiling is rounding a number to the next number with specified precision :

CEILING(number, precision)

For example, if your min lot step is 0.01 :
If calculated lot size is 1.2568 : CEILING(1.2568, 0.01) = 1.26
If calculated lot size is 1.2562 : CEILING(1.2562, 0.01) = 1.26

If min lot step was 0.1 :
If calculated lot size is 1.2568 : CEILING(1.2568, 0.1) = 1.3
If calculated lot size is 1.2562 : CEILING(1.2562, 0.1) = 1.3

It is allowing to round calculated lot size to an acceptable lot size for the EA, otherwise it would probably send a 131 error when trying to send trades.
Author:  Dewey McG [ Sun Jul 20, 2014 1:49 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

SpiderX » Thu Jul 17, 2014 10:28 pm wrote:Hi Dewey,

Got the answer after looking again.

For first 2 orders
buyprice: 190.368 close: 188.368 pips:-200 lot:(0.25) pipx lot: -50
sellprice: 189.868 close: 188.426 pips:144.2 lot:(0.34) pipx lot: 49.028

Overall: -0.972 pip.lot

Second order didnt close at the tp.

If it closed at tp:

pips:-200 lot:(0.25) pipxlot: -50
pips:150 lot:(0.34) pipxlot: 51

Overall : +1 pip.lot

Calculation should be correct.
Issue is that recovery trades did not close at tp, maybe that is something that has to be accounted for.

Cheers
I spent almost all of yesterday removing a nasty virus from my computer, so I didn't get a chance to really go over this until this morning. The calculations are fine, but why did this not close at tp? This was a back test. I understand with live trading there will be slippage etc., but don't understand why this would happen in a back test. Is this Empty4 acting up again?

The good news is that the EA does work and will make a profit of careful, though we need to work on risk settings. .25 would be way too much
Author:  SpiderX [ Sun Jul 20, 2014 2:13 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Dewey McG » Sun Jul 20, 2014 9:49 pm wrote:
I spent almost all of yesterday removing a nasty virus from my computer, so I didn't get a chance to really go over this until this morning. The calculations are fine, but why did this not close at tp? This was a back test. I understand with live trading there will be slippage etc., but don't understand why this would happen in a back test. Is this Empty4 acting up again?

The good news is that the EA does work and will make a profit of careful, though we need to work on risk settings. .25 would be way too much

Hi Dewey,

It depend on the test settings.
In the new version, once the buys or sells hits sl and close, the opposing buys/sells might not have hit tp and be forced to close too.
My guess it that in real situation, they should both hit tp and sl together...provided the spread is not too ridiculous.
But in the event the spread widens and for example the buys hit sl, the sells might not have hit tp...The EA will force close the sells at market...and it give the situation that we see.
it would be a small loss..but maybe you need a small buffer to take into account this kind of situations.

Cheers
Author:  Dewey McG [ Sun Jul 20, 2014 10:41 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

I think you are right. The main thing is that losses become either very small, small profits or breakeven so we can get the most out of the winners
Author:  kotsh [ Mon Jul 21, 2014 9:12 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

I have been following the main ALR thread and was wondering why it got quiet..
Should have checked in this section of the forum earlier :)


Great job writing this sophisticated EA!

I have one suggestion thought for closing the trades, since we are closing hedged trades, it seems we can save some spreads and commissions by closing the trades using the CloseBy() fucntion described here:

http://book.mql4.com/trading/orderclose
(in the bottom of there is an example code)


rather than simply closing the orders. With a high number of turns, I think it would make a difference.
Author:  falanca [ Tue Jul 22, 2014 12:01 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

There are many forex gurus here but ı have some ideas about this miracle idea!.ALR. think its latest aim must be to opena neworder with the lot that will get estimated profit on the estimated pips that reached.So it can be coded useable for every EA that opens controrders(buys and sells)

We must see the eguity profit and the total numbers of buy and sell orders on the scene.

Starting Equity;for example 100
Eguity profit percentage aim;1
Total numbers of buy orders;1.5
Total numbers of sell orders;3
Equity now;98 percentage loss;%2
Pip aim;100(İt must calculate the new orders lot to profit %1 on 100 pips when opening the new order)

İ hope ı could manage what ı ment .İt can be coded eitherly in order to use with many orders or can be attached to any ea.İsnt it worth to discuss.
Author:  SpiderX [ Tue Jul 22, 2014 12:54 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

kotsh » Mon Jul 21, 2014 5:12 pm wrote:I have been following the main ALR thread and was wondering why it got quiet..
Should have checked in this section of the forum earlier :)

Great job writing this sophisticated EA!

I have one suggestion thought for closing the trades, since we are closing hedged trades, it seems we can save some spreads and commissions by closing the trades using the CloseBy() fucntion described here:

http://book.mql4.com/trading/orderclose
(in the bottom of there is an example code)

rather than simply closing the orders. With a high number of turns, I think it would make a difference.
Hi

Thanks for pointing this out.
Looks like it would be a more elegant solution.
Will look at how to incorporate it.

Cheers
Author:  Gordon [ Sat Jul 26, 2014 3:34 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

This thread has been dead for five days. :o
Author:  SpiderX [ Sat Jul 26, 2014 3:39 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Gordon » Sat Jul 26, 2014 11:34 pm wrote:This thread has been dead for five days. :o
Thanks for the post.
Is this OOTB ?

Working still on the next version. :)

Cheers
All times are UTC Page 8 of 14