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

Automatic Loss Recovery System (ALR) - read this first
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3682
Page 27 of 40
Author:  TheInsider [ Mon Aug 11, 2014 10:37 am ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

ALR_with_Spread_v8.5-mod.zip
Dewey McG » Mon Aug 11, 2014 4:01 am wrote:Here is what I mean. I put this new one on FinFX's ECN Pro Demo. The progression of trades goes from .1 to .2 and on up but always rounds up. The correct 2nd trade for instance would be .14, not .2 See PICs of EA on chart and the spreadsheet
On FinFx the lowest start lot is 0.1 but lotstep is 0.01, so lot size cannot be less than 0.10, but can be 0.11, 0.12, 0.13 etc. And this is the case with most brokers - that the lotstep is 0.01.

In he EA "ALR_with_Spread" the lot size is rounded up by adding the value 0.00499, which I don't believe is the the correct way to do it.

The picture below shows the lot increment (based on the same test for date 2014.01.06 - see my last post).

# = number of increments / number of opened hedged positions
A = Original ALR
B = ALR_with_Spread_v8.5-mod - my modded version without the added 0.00499 rounding value
C = ALR_with_Spread_v8.5 with this rounding
ALR-Lot-compare.png
As can be seen, adding this rounding value of 0.00499 ( C ) makes the lot size to increase more and more far away from a non-rounded value ( B ). However, the original ALR ( A ) seem to make some rounding, but not in the way the ALR_with_Spread does it.

Personally, I don't think any of the 3 calculates the lot size correctly due to the fact that all 3 tests ended up with losses. Because if they had, then the result would have been about +50 (which was the profit goal in case the first position did not hit TP). Instead the results was as follows:

A = -407.92
B = -414.57
C = -433.26

I have now overruled this rounding in my modded version, which I have attached here! The reason for doing so, is that it's more like the original ALR.
Author:  Dewey McG [ Mon Aug 11, 2014 1:31 pm ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

TheInsider » Mon Aug 11, 2014 6:37 am wrote:
On FinFx the lowest start lot is 0.1 but lotstep is 0.01, so lot size cannot be less than 0.10, but can be 0.11, 0.12, 0.13 etc. And this is the case with most brokers - that the lotstep is 0.01.

In he EA "ALR_with_Spread" the lot size is rounded up by adding the value 0.00499, which I don't believe is the the correct way to do it.

The picture below shows the lot increment (based on the same test for date 2014.01.06 - see my last post).

# = number of increments / number of opened hedged positions
A = Original ALR
B = ALR_with_Spread_v8.5-mod - my modded version without the added 0.00499 rounding value
C = ALR_with_Spread_v8.5 with this rounding

Image < == Picture here! BTW, how to add pictures directly?! Img here does not automatically load external pics.

As can be seen, adding this rounding value of 0.00499 ( C ) makes the lot size to increase more and more far away from a non-rounded value ( B ). However, the original ALR ( A ) seem to make some rounding, but not in the way the ALR_with_Spread does it.

Personally, I don't think any of the 3 calculates the lot size correctly due to the fact that all 3 tests ended up with losses. Because if they had, then the result would have been about +50 (which was the profit goal in case the first position did not hit TP). Instead the results was as follows:

A = -407.92
B = -414.57
C = -433.26

I have now overruled this rounding in my modded version, which I have attached here! The reason for doing so, is that it's more like the original ALR.
Awesome job--thanks!
Author:  Dewey McG [ Tue Aug 12, 2014 1:10 am ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

The problem is still there. I cans see why it would move .09 to .1, but not why .14 changes to .20
Author:  TheInsider [ Tue Aug 12, 2014 11:45 pm ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

The formula for calculating the new lot size in "ALR_with_Spread" seem to be almost identical to the formula in the original (for which I don't have the source code), and it's as follows:

For BUYSTOP

CalcLots = ( ( ( TakeProfit + StopLoss + spread ) * SellLots / TakeProfit ) - BuyLots ) + ( Profit ) / tikV / TakeProfit;

For SELLSTOP

CalcLots = ( ( ( TakeProfit + StopLoss + spread ) * BuyLots / TakeProfit ) - SellLots ) + ( Profit ) / tikV / TakeProfit;

To understand the formula better we can reduce it assuming that we have the following:

TakeProfit = 1500 (Note: 150 pips = 1500 points as calculations are in Points)
StopLoss = 500 (Note: 50 pips = 500 points as calculations are in Points)
Profit = 50 (called XYZ in unmodified "ALR_with_Spread")
tikV = 1.0 (if the counter currency is USD, like EURUSD, and account currency is USD then this value is 1).
spread = 0. My tests shows that adding spread have no impact on the lot size calculation.

BUYSTOP lot = ( ( ( 1500 + 500 ) * SellLots / 1500 ) - BuyLots ) + ( 50 ) / 1.0 / 1500, which we reduce to...

BUYSTOP lot = 2000 * SellLots / 1500 - BuyLots + ( 50 / 1500 ), which we reduce to...

BUYSTOP lot = 2000 * SellLots / 1500 - BuyLots + 0.03333333

And for SELLSTOP we get...

SELLSTOP lot = 2000 * BuyLots / 1500 - SellLots + 0.03333333

Now, using the above formulas and 2014.01.06 as sample, and starting with a SELL the lot increments are as can be seen in the attached Excel, which can be used to calculate the lot size depending on what the StopLoss, TakeProfit, Profit, etc. are.

Enjoy :)
Author:  blazecrown [ Wed Aug 13, 2014 2:42 am ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

Hi TheInsider, thank you so much for sharing the formulas you're using... great help to us non-programmers in understanding this ALR EA...

i got few questions though:

as it is, your formulas look different from what we've been using thus far, which are (without the spread):
H(n) = [(sum_of_P(n-1)+A)(z+h) + 0.1*C]/h – sum_of_H(n-1)
P(n) = [(sum_of_H(n)(z+h) + 0.1*C]/p - [sum_of_P(n-1) + A]
where H(n) is the lot size calculation for opposite direction, P(n) is the lot size calculation for same direction, z is the ALR zone, p is the T/P zone for same direction, h is the T/P zone for opposite direction, A is the original lot size...
1. can you share with us how are they different?
tikV = 1.0 (if the counter currency is USD, like EURUSD, and account currency is USD then this value is 1)
i like the fact that you've taken into consideration the tikV in your calculation.
2. may i know in the program calculation, what the tikV be for non-USD based currency pairs, like GBPJPY or EURJPY for example.
spread = 0. My tests shows that adding spread have no impact on the lot size calculation.
3. i believe spread would have no impact in the calculation as long as, i assume in the program, it buys at the Ask and sells at the Bid, and accordingly the user enters his/her StopLoss parameter inclusive of the spread already. would this be correct?

thanks...
Author:  Fibotrend [ Wed Aug 13, 2014 11:16 am ]
Post subject:  Automatic Loss Recovery System (ALR)

kotsh » Sat Jul 12, 2014 8:42 am wrote:Hi Fibotrend,

this idea also crossed my mind, but if you try to implement it with an EA it is not practical.

Lets say your first hedge trade is 50 pips away from entry. It opens and price goes 10 pips into it then reverses back in original direction, so you close the hedge when (the hedge) is at BE. Now lets say on the way back in your original position favour, it oscillates at the -50 pips level dome time, It goes for example from -48 to -52 pips 10 times, this means you would every time open and close the hedge trade, paying spread and commissions, plus it is very painful to watch :)

You idea would much better be implemented manually, for example if the hedge goes to BE, you can put a pending order 10-15 pips BELOW the first hedge and increase hedge position size, so in case it reverses again you still catch it with the hedge, but you are at the same time giving it room to move in the ALR zone.
I've been playing around with numbers and thanks to Kotsh advice I've developed a trailing ALR version. What I'm trying to achieve is killing the trade ASAP after the hedge position kicks in. Therefore I thought we should have a recovery zone for the hedge, the same way we have it on the original trade.
Alr.jpg
The ratio 1:3 works well, as those levels correspond to fibo's likely to be hit. In our example we open the 2nd hedge 15pips above the -50 level, then we put a sell order 30pips below for the short hedge. As this trade has a long bias we keep trailing our orders in this way, long hedges 15pips above, short hedges 30pips below.

Since we are opening each position closer to each other, lot sizes are much smaller when compared to the original ALR version:

1 = 0.1
2 = 0.134
3 = 0.065
4 = 0.08
5 = 0.085
6 = 0.106
7 = 0.113
8 = 0.145
9 = 0.155
10 = 0.206
11=0.218

The smaller the lot size the smaller the margin, risk and exposure. Unfortunately I don't have any formulas or spreadsheet for the model. I've worked out the size for each hedge manually, any help from the math gurus in the forum would be very appreciated. :smile:

Another huge plus is that the orders are shifting away from the ALR zone. Basically if the price keeps bouncing in the range it will trigger 5 orders only.

Any feedback is welcome. Cheers
Author:  TheInsider [ Wed Aug 13, 2014 11:58 am ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

The formulas I use in Excel comes from "ALR_with_Spread" that member Wealthmaster has provided.

The formulas you refer to have one missing variable - C. What is this?

I guess you got the formulas and explanations from somewhere else (in this forum)? Can you please state a link to this place?

Before I know where they come from, and what the variable C stands for I cannot say anything.

TickValue in MQL can be fetched from the broker with the following MQL-code:

MarketInfo ( Symbol(), MODE_TICKVALUE );

Attached is a script for Empty4 that I've written (place it in MQL4 / Scripts and restart Empty4, then attach it to a chart). It run once and shows lots of information printed in the Terminal -> Experts tab window, including "Tick Value".

For manual calculation, it's 1.0 for all XXX / USD pairs where Account Currency is USD, and 1 / BID for all USD / XXX pairs where Account currency is USD. For crossings and if account currency is not USD then the calcuilation is little more complex. So it's easier to use the inbuilt MQL-command above.
Author:  blazecrown [ Wed Aug 13, 2014 1:22 pm ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

The formulas you refer to have one missing variable - C. What is this?
oh, sorry i missed that... variable C stands for Target Profit in $...
I guess you got the formulas and explanations from somewhere else (in this forum)? Can you please state a link to this place?
you can find the formulas within the spreadsheet ALR Calculator... here's a link, (find ALR Calculator v2.1): http://www.stevehopwoodforex.com/phpBB3 ... &start=160
TickValue in MQL can be fetrched from the broker with the following command...

MarketInfo ( Symbol(), MODE_TICKVALUE );

Attached is a script for Empty4 that I've written (place it in MQL4 / Scripts and restart Empty4, then attach it to a chart). It run once and shows lots of information printed in the Terminal -> Experts tab window, including "Tick Value".

For manual calculation, it's 1.0 for all XXX / USD pairs where Account Currency is USD, and 1 / BID for all USD / XXX pairs where Account currency is USD. For crossings and if account currency is not USD then the calcuilation is little more complex. So it's easier to use the inbuilt MQL-command.
wow! awesome... super thanks...
Author:  TheInsider [ Wed Aug 13, 2014 2:58 pm ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

blazecrown » Wed Aug 13, 2014 3:42 am wrote: <snip>
i got few questions though:

as it is, your formulas look different from what we've been using thus far, which are (without the spread):
H(n) = [(sum_of_P(n-1)+A)(z+h) + 0.1*C]/h – sum_of_H(n-1)
P(n) = [(sum_of_H(n)(z+h) + 0.1*C]/p - [sum_of_P(n-1) + A]
where H(n) is the lot size calculation for opposite direction, P(n) is the lot size calculation for same direction, z is the ALR zone, p is the T/P zone for same direction, h is the T/P zone for opposite direction, A is the original lot size...
1. can you share with us how are they different?
I've now looked through the different Excel-files that have been posted here for ALR. All that I can say, is that the formulas and the lot result differs from the original ALR. The EA "ALR_without_spread" was according to Wealthmaster a bought programming job based on the original ALR, which also is the reason why the lot size is so close to the original ones. The other ones produce other lots sizes. I'm not saying that the others calculate it wrong, but it's not in the same way.

I will have to analyze the formulas that you posted to understand exactly what they calculate),

And I urge those who are behind the other xls-files for ALR to explain why the formulas look like they are.

BTW, I will now re-upload "ALS-Calculation.xls" (no important changes, just separated the column ALR-original and added some explanatory text).

Ps. Also, I cannot see any reason to have a separate formula for "calculation in the same direction" - P(n) - as every new position is hedged against the last one, so it will always be in the opposite direction!
Author:  Lagrange [ Thu Aug 14, 2014 10:47 am ]
Post subject:  Automatic Loss Recovery System (ALR) - read this first

Hi,

I am not sure if i fully understand this ALR II concept.
It seems to take a loss for the first entry and then enter in opposite direction etc. etc.
Can anybody give me a hint or link where to read more about this modification?

Thanks Lagrange
All times are UTC Page 27 of 40