Rounds up to the next 0.01
Cheers
Trend Trading EA with Automated Loss Recovery
- SpiderX
- Trader
- Posts: 554
- Joined: Thu Aug 22, 2013 4:50 pm
Trend Trading EA with Automated Loss Recovery
"Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It does not dishonor others, it is not self-seeking, it is not easily angered, it keeps no record of wrongs.Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres."
-Corinthians 13:4-8
-Corinthians 13:4-8
- Elixe
- Trader
- Posts: 98
- Joined: Tue Jun 04, 2013 6:44 pm
- Location: France
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.
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.
-
Dewey McG
- Trader
- Posts: 435
- Joined: Sat Nov 26, 2011 4:20 pm
- Location: Tampa FL
Trend Trading EA with Automated Loss Recovery
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?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
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
- SpiderX
- Trader
- Posts: 554
- Joined: Thu Aug 22, 2013 4:50 pm
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
"Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It does not dishonor others, it is not self-seeking, it is not easily angered, it keeps no record of wrongs.Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres."
-Corinthians 13:4-8
-Corinthians 13:4-8
-
Dewey McG
- Trader
- Posts: 435
- Joined: Sat Nov 26, 2011 4:20 pm
- Location: Tampa FL
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
-
kotsh
- Trader
- Posts: 31
- Joined: Mon Sep 02, 2013 1:58 pm
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.
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.
-
falanca
- Trader
- Posts: 31
- Joined: Tue Mar 04, 2014 2:23 pm
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.
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.
- SpiderX
- Trader
- Posts: 554
- Joined: Thu Aug 22, 2013 4:50 pm
Trend Trading EA with Automated Loss Recovery
Hikotsh » 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.
Thanks for pointing this out.
Looks like it would be a more elegant solution.
Will look at how to incorporate it.
Cheers
"Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It does not dishonor others, it is not self-seeking, it is not easily angered, it keeps no record of wrongs.Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres."
-Corinthians 13:4-8
-Corinthians 13:4-8
- Gordon
- Trader
- Posts: 19
- Joined: Wed Feb 22, 2012 7:02 pm
Trend Trading EA with Automated Loss Recovery
This thread has been dead for five days. 
You do not have the required permissions to view the files attached to this post.
- SpiderX
- Trader
- Posts: 554
- Joined: Thu Aug 22, 2013 4:50 pm
Trend Trading EA with Automated Loss Recovery
Thanks for the post.Gordon » Sat Jul 26, 2014 11:34 pm wrote:This thread has been dead for five days.
Is this OOTB ?
Working still on the next version.
Cheers
"Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It does not dishonor others, it is not self-seeking, it is not easily angered, it keeps no record of wrongs.Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres."
-Corinthians 13:4-8
-Corinthians 13:4-8