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 4 of 14
Author:  SpiderX [ Sun Jul 13, 2014 2:23 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Dewey McG » Sun Jul 13, 2014 1:10 am wrote:I finally had a chance to do some testing. I used the EURNZD and have attached the preset so you can check to make sure I didn't make any errors. The good news is that it works well in that the most turns over the last 5 years was 7 and it makes a nice little profit. The bad news is that there are some errors in that the lot sizes are not calculated correctly. The sequence with .1 lots should go as follows: 0.10, 0.14, 0.09, 0.12, 0.17, 0.22, 0.29, 0.39, 0.52, 0.70, 0.93 1.24 1.66, 2.21, 2.95. The EA goes .2, .2, .1, .2, .2 etc.
Hi Dewey,

Does your broker has min lots 0.1 ? or somehow there is min lots 0.1 in your test ?
It works fine on my end for ALR lot size. Still a bit of work needed.

Cheers
Author:  madpipa [ Sun Jul 13, 2014 2:26 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Dewey McG » Sun Jul 13, 2014 3:10 am wrote: ... The bad news is that there are some errors in that the lot sizes are not calculated correctly. The sequence with .1 lots should go as follows: 0.10, 0.14, 0.09, 0.12, 0.17, 0.22, 0.29, 0.39, 0.52, 0.70, 0.93 1.24 1.66, 2.21, 2.95. The EA goes .2, .2, .1, .2, .2 etc.
Hi Dewey,

I just ran the EA and got lot sizes as follows: 0.10, 0.13, 0.07, 0.09, 0.12, 0.16, 0.21, 0.27, 0.36, 0.48, 0.64. These don't agree exactly with my calculations but are fairly close. But I am ignoring spread. I have taken the approach to keep lot sizes as small as possible along the way - hence ignoring spread & swap for lot size calculations. At the end of the legs my EA has to go further to get to the point where it is a breakeven trade. Two different ways to do the same thing. I think Spider's approach is to reach breakeven by the pre-set TP level. Works well, but the disadvantage is larger lot sizes to reach the goal.

As for your problem with the weird lot sizes?? Are you sure this demo account allows you to open micro lots? I know one of my Alpari UK accounts does but the others are all mini lots. A mini lot account would give you trades like you mentioned.

Cheers,
Mick
Author:  madpipa [ Sun Jul 13, 2014 3:38 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

... Being handicapped here in the U.S. with no hedging, I also consider to buy only on EURUSD and sell only on the EURCAD for instance.
I feel sorry for you Gordon. Hedging can be useful (if you can control it). But the ALR concept should still work OK. I have always intended to use it in a non-hedging way; if it proves viable. I have written most of my EAs using hedging as I find it conceptually easier to follow the logic & graphically easier to watch the trades build & finally close during backtesting. The hedge approach cost more as you are carrying swap costs, sometimes for days. Brokers would love it!!

Have a look at this exert from my simple spreadsheet:
trades.png
The important thing to look at is the Nett Lot Size. The 1st trade is opened with 0.10 lots. The second is 0.14 lots, 3rd is 0.09 lots.

The better way to do it is to close the 1st trade when it reaches the SL/ALR & open the 2nd trade with 0.14 - 0.10 = 0.04 lot size. The 3rd trade would then mean closing the 2nd & opening a trade = 0.05.

In the backtest I just ran on EURNZD it opened the first trade on March 25 & closed the 11 trades on May 8. That is a lot of swaps, especially with the differential in the 2 currencies' Central Bank Rates. By closing each trade when it reaches one side of the ALR and only opening the smaller nett size trade it helps to dramatically reduce the swap costs.
Author:  Dewey McG [ Sun Jul 13, 2014 4:22 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

SpiderX » Sat Jul 12, 2014 10:23 pm wrote:
Hi Dewey,

Does your broker has min lots 0.1 ? or somehow there is min lots 0.1 in your test ?
It works fine on my end for ALR lot size. Still a bit of work needed.

Cheers
My bad--I used a new broker for back-testing because the one I was using doesn't have the EURNZD. I ran this on the EURCHF but there are still problems with lot size progressions and that it gives a big loss when you have several turns instead of a small profit or break even.
Author:  SpiderX [ Sun Jul 13, 2014 5:06 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Dewey McG » Sun Jul 13, 2014 12:22 pm wrote:
SpiderX » Sat Jul 12, 2014 10:23 pm wrote:
Hi Dewey,

Does your broker has min lots 0.1 ? or somehow there is min lots 0.1 in your test ?
It works fine on my end for ALR lot size. Still a bit of work needed.

Cheers
My bad--I used a new broker for back-testing because the one I was using doesn't have the EURNZD. I ran this on the EURCHF but there are still problems with lot size progressions and that it gives a big loss when you have several turns instead of a small profit or break even.

Not sure what settings you are using....but cant seems to get the same lot sizes as you.
Are you using the correct version ?

Cheers
Author:  SpiderX [ Sun Jul 13, 2014 5:30 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

v1.03a is in post 1.

v1.03a
-Some bug fixes in InitializeALRPositions, this should fix the issue of wrong lot sizes
-Initialize ALR to round up lots to next lot step in lot size calculation


Dewey,

There is an issue in backtesting...where for some reason the price has already moved past the buy entry price for pending order of the next ALR position.
i.e:EA tried to place buystop for next leg, but price already above buy entry.
This creates SendOrder Error 130 in the backtest.
Think this should be something only present in backtesting with unprecise data. Since usually the buystop would be placed after the previous sellstop has triggered.

Cheers
Author:  SpiderX [ Sun Jul 13, 2014 5:59 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

Just tested out backtesting in visualmode on GBPJPY.
Seems to be working fine and correctly.

Thus my proposal: For "backtesting", use visual mode , set it to highest speed.

Attached is my "backtesting" on GBPJPY, seems fine.
Note : "Backtesting" because it tells m the EA works, but does not reflect actual performance in the market.

Cheers
Author:  theforexedge [ Sun Jul 13, 2014 7:51 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

SpiderX » Sun Jul 13, 2014 5:30 am wrote:v1.03a is in post 1.

v1.03a
-Some bug fixes in InitializeALRPositions, this should fix the issue of wrong lot sizes
-Initialize ALR to round up lots to next lot step in lot size calculation


Dewey,

There is an issue in backtesting...where for some reason the price has already moved past the buy entry price for pending order of the next ALR position.
i.e:EA tried to place buystop for next leg, but price already above buy entry.
This creates SendOrder Error 130 in the backtest.
Think this should be something only present in backtesting with unprecise data. Since usually the buystop would be placed after the previous sellstop has triggered.

Cheers
SpiderX

Can you post the code as well? as its always good to learn from the code changes :yahoo:

Thanks, JP
Author:  moncsicsi78 [ Sun Jul 13, 2014 8:44 am ]
Post subject:  Trend Trading EA with Automated Loss Recovery

This ALR strategy is not good...
And it would be better to build an EA which can only open trades in the direction of the trend (buy stop and sell stop orders), with decreasing lot size (this is the rule of building pyramide trades), and use a trailing stop before every new level triggering.
If a new level is triggered, but before trailing stop is activated, and the price turns against us, at this point should start an "ALR mode"!
BUT!
If the price is breaking out form ALR zone in any direction, the EA should start to open pyramid orders in that direction with the rules mentioned above.

But the rules of ALR should be:
- adjustable lot multiplier
- adjustable SL, TP and ALR zone size, etc.
Author:  Dewey McG [ Sun Jul 13, 2014 12:50 pm ]
Post subject:  Trend Trading EA with Automated Loss Recovery

SpiderX » Sun Jul 13, 2014 1:30 am wrote:v1.03a is in post 1.

v1.03a
-Some bug fixes in InitializeALRPositions, this should fix the issue of wrong lot sizes
-Initialize ALR to round up lots to next lot step in lot size calculation

Dewey,

There is an issue in backtesting...where for some reason the price has already moved past the buy entry price for pending order of the next ALR position.
i.e:EA tried to place buystop for next leg, but price already above buy entry.
This creates SendOrder Error 130 in the backtest.
Think this should be something only present in backtesting with unprecise data. Since usually the buystop would be placed after the previous sellstop has triggered.

Cheers
I get history using tickstory and my tests show 0 mismatched chart errors--would there still be issues as you described?
All times are UTC Page 4 of 14