Trend Trading EA with Automated Loss Recovery

Post your EA's using ALR here
Post Reply
User avatar
SpiderX
Trader
Posts: 554
Joined: Thu Aug 22, 2013 4:50 pm

Trend Trading EA with Automated Loss Recovery

Post by SpiderX »

SERIOUS WARNING
Most Forex traders lose all their money.
Using the robot posted here in trading Forex does not guarantee success.
Trading this robot could lead to serious financial loss.
Trading this robot without understanding its underlying trading strategies guarantees traders will lose their money.
This is not a set-and-forget ea; there is no such thing and anyone who tries to claim there is, is either stupid or lying. This ea requires frequent manual intervention.
At best, a trading robot is only 90% as good as the manual strategy it trades. At best. At worst, it can be much less effective. If the strategy is rubbish, so is the robot.
To trade this robot, you have to understand:
How to use EA's.

THIS IS AN EXPERIMENTAL EA NOT YET BEING USED ON OUR LIVE ACCOUNTS


This EA is a result of the discussion from :
http://www.stevehopwoodforex.com/phpBB3 ... =23&t=3682
http://www.stevehopwoodforex.com/phpBB3 ... =12&t=3708

USE THIS ON A 4H CHART ONLY

Trading Rules
Long Trade Entry
1. Price is above 240 Lwma
2. MACD Main signal below 0
3. Price open below 5ema shift 5 and close above

Long Exit:
1. Trade is in profit
2. Price opens above 5ema shift 5 and close below

Short Trade Entry
1. Price is below 240 Lwma
2. MACD Main signal above 0
3. Price open above 5ema shift 5 and close below

Short Exit:
1. Trade is in profit
2. Price opens below 5ema shift 5 and close above

Trade Exits will be invalid once first ALR trade has trigger.
After recovery trade has triggered, trades will exit either by sl or tp.
Please do not use Stoploss management with ALR as it will mess things up.


The EA is coded on a customized shell , which is a hybrid of Steve's and Tommaso.
The good thing is that most of the code is designed to be efficient and reduce CPU cycles in processing of the EA,
but the down side is that it is relatively untested compared to Steve's/Tommaso shell and there could be some bugs lurking around.(though hopefully unlikely)

Please test out this initial version and see if you encounter any bugs or errors.
Currently, the lot size setting if using FixedLot = false, is based on the Stoploss value, as such it is recommended to do your own Math and set StopLoss to be equal to (ALRZonePips + ALRTargetPipsOppDir).

At this point of time, it is nice if someone can backtest this EA on Empty4 in tick mode, just for sanity checking purpose. (Didnt manage to do this due to time constraints)
Dewey was testing out earlier and it seems to be fine (as long as the backtesting is not in candle mode)

Code: Select all

extern string   gen0a="====Automated Loss Recovery Settings====";
extern bool   useAutomatedLossRecovery = true;
extern double ALR_ZonePips                    = 50;
extern double ALR_TargetPips_SameDir   = 150;
extern double ALR_TargetPips_OppDir     = 150;
extern double ALR_TargetProfitDollars     = 10.0;
extern double ALR_DollarPerPipLot          = 10.0;
extern int    ALR_MaxTrades                   = 10;     
extern double ALR_SpreadPips           = 1;
The ALR settings can be adjusted as the above parameters and they are almost exact as per Dewey's spreadsheet.
Hopefully Dewey can recommend some settings and will hardcode it into the EA.


To do list:
1. Update more details on the EA in post 1.
2. Add ALR_PercentRisk parameter based on worse case loss when ALR sequence ends with a loss
3. Initial lots and risk calculation to be based on ALR settings rather than stop-loss when useAutomatedLossRecovery is enabled true.

Version Updates:
v1.01
-Added in code in consideration of ALR Max Trades Limit. (Forgot about this one)

v1.02
-Add trade comments to make trades more traceable
-Some code clean up and minor efficiency enhancements

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
-Note: If you are "backtesting" , try using visual mode at highest speed.

v1.03b
-Add tracking of number of positions in code
-If there is a discrepancy in positions, EA will close all positions for safety.

v2.00
-Major rework of ALR concept
-Initial trade is closed and loss is taken, while the next order in the opposing direction is opened.
-Basically, the next order in the opposing direction is taken to cover the losses of the previous trades
This results in smaller positions and smaller losses for same number of turns.
ALR Variables:

Code: Select all

extern bool   useAutomatedLossRecovery = true;
extern double ALR_ZonePips             = 50;
extern double ALR_TargetPips_SameDir   = 150;
extern double ALR_TargetPips_OppDir    = 150;
extern double ALR_ProfitPips           = 10.0;
extern double ALR_CommissionPips        = 1.0;
extern int    ALR_MaxTrades            = 10;    
extern double ALR_MaxLots              = 5.0;
ALR_ProfitPips is the number of addition pips in profit to add to each trade cycle.
ALR_CommissionPips is the number of pips your broker charges as commission which has to be taken to consideration with each trade that is closed.
ALR_MaxLots limits the maximum lots possible in the ALR progression and it supercedes ALR_MaxTrades.
If ALR_MaxLots is exceeded, then ALR_MaxTrades will automatically be toned down.

v2.01
-Patched in a missing line in the error catching code

v2.02
-Add in missing code to remove all pending trades when original trades are closed by the EA

v2.03
-More options to adjust timeframe for indicators
-The Timeframe settings for all indicators default to 0, which is chart tf settings.
Please look at variables:

Code: Select all

extern int      MACD_FastEMAPeriod =0;
extern int      TradingTimeFrame   =0;
extern int      FastMaTdTF    =0; 
extern int      SlowMaTdTF    =0;
v2.04
-Fixed bug that caused lot size calculation to be wrong
-Fixed bug that caused lot size of recovery trades to be wrong

v2.05
-Code improvements to better adjust profit at the end of the ALR progression
-The target price is no longer static and is adjusted slightly to precisely achieve the target profit.
-Please use ALR_ProfitPips if you like more profit at the end of the ALR progression.

v2.06
-Removed ALR_ProfitPips and replaced with ALR_TargetPercentProfit
Use this to set the target percent profit you wish to have at the end of an ALR progression
0 is ok, if you wish to minimize lot sizes, anything higher means higher lot sizes.
i.e: if you set 0.1%, you get a 0.1% profit for your account at the end of each ALR Progression upon hitting tp.

-new variable ALR_MaxPercentLoss
Determines the maximum hit to the account for ALR progression and supercedes MaxALRTrades
Use this to protect your account from more losses than acceptable.
i.e: for 20%, the maximum hit your account can take is 20% and no more.

Code: Select all

extern double ALR_TargetPercentProfit  = 0.1;
extern double ALR_MaxPercentLoss       = 20;
Cheers
You do not have the required permissions to view the files attached to this post.
Last edited by SpiderX on Mon Jul 14, 2014 4:19 pm, edited 12 times in total.
"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
User avatar
SpiderX
Trader
Posts: 554
Joined: Thu Aug 22, 2013 4:50 pm

Trend Trading EA with Automated Loss Recovery

Post by SpiderX »

ALR2.0 Trade Manager

This was a request from Dewey.
ALR2.0 Trade Manager will automatically manage any trade for the symbol with the same Magic number as the setting in the EA.
It will create a pending once there is a trade with the same Magic number, and this would be deleted if the trade was not stopped out.
Additional variable: ALR_AutoTPandSL
If set true, this ignores ALR_TargetPips and ALR_Zone, the target pips and zone pips are set according to the TP and SL of the initial trade.
If this is set false, the trade manager will automatically adjust the initial trade tp and sl to ALR_TargetPips_SameDir and ALR_ZonePips .

Trade manager moved here:
http://www.stevehopwoodforex.com/phpBB3 ... 792#p97774

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
User avatar
SpiderX
Trader
Posts: 554
Joined: Thu Aug 22, 2013 4:50 pm

Trend Trading EA with Automated Loss Recovery

Post by SpiderX »

Hi,

Need to upload v1.01 as something just occured to me.

v1.01
-Added in code in consideration of ALR Max Trades Limit. (Forgot about this one)

ALRTrade management will exit onces the ALR_MaxTrades are reached.

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
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Trend Trading EA with Automated Loss Recovery

Post by SteveHopwood »

Fantastic stuff Spi. :clap: :clap: :clap:

I shall try to draw attention to this.

Any time you need another post at the top of this thread, post it as normal then ask Tommaso to change the time and date stamp and your new post will appear where you want it.

:xm:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Trend Trading EA with Automated Loss Recovery

Post by milanese »

Looks interesting, great work Spider!! :clap: :clap:

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Trend Trading EA with Automated Loss Recovery

Post by dudest »

You got mad skillz bro!, good show :)
User avatar
Eamonn
Trader
Posts: 87
Joined: Wed Nov 16, 2011 6:45 am

Trend Trading EA with Automated Loss Recovery

Post by Eamonn »

With the right settings this could be just what us mere retail traders need to have any chance of success,

thanks a lot team, oh and lets not forget that Dustin Pass is selling his ALR system for $ 1997.00



Eamonn.
Dewey McG
Trader
Posts: 435
Joined: Sat Nov 26, 2011 4:20 pm
Location: Tampa FL

Trend Trading EA with Automated Loss Recovery

Post by Dewey McG »

Great work Spider!

Just remember folks, this whole concept is still in the testing phase to see how viable it is. No matter how tempting don't try on a live account. Test it, experiment, try every combination you can think of and share results.
User avatar
pips400
Trader
Posts: 279
Joined: Tue Jan 01, 2013 9:03 pm

Trend Trading EA with Automated Loss Recovery

Post by pips400 »

Thank you sooooooooo much guys for all your effort on this project. You've reached a new horizon by pushing the boundaries of what can be done. Like other's I'll test this out on demo and feedback anything that may be useful :good:

:!!:
erikskenne
Trader
Posts: 62
Joined: Fri Mar 30, 2012 6:27 pm

Trend Trading EA with Automated Loss Recovery

Post by erikskenne »

Fantastico :yahoo: :clap: :clap: :clap:
Post Reply

Return to “Automated Loss Recovery”