A few days ago I received a PM to code an EA with the following parameters:
-User decides initial trade direction (let's say long) and starting lot size (say .1 lot)
-New position would be added every time the market moves x pips (say 10 pips) up or down away from the most recent position taken. If market moves up from the original position 10 pips a new long is added. If the market moves down 10 pips from the last position a short is added (basically following the market looking to catch a trend in either direction).
-Each new position size increased by x (ex: .1 lot)
-Take profit based on account %
-Stop loss based on account %
-Max number of standard lots before EA can't taken any new positions (at this point the T/P or S/L will need to be hit when max is reached)
-Re-enter mode would start a new progression again once the prior progression has ended do to T/P or S/L being hit
-Magic number to run on multiple pairs
I did my best to code such an EA.
PLEASE read ALL the comments in the code to understand the external variables. Default settings are just a guess, testing and optimization needs to be performed.
I'm not sure if this strategy is viable, these type of experts can get you into trouble quick!
So use for testing only!
Edit:If you are new to this thread, the latest version is posted below. This is the eighth version I have made as a result to this thread.
Please read thread thoroughly to fully understand this EA.
Enjoy.
Explanation of external variables:
PHP Code:
extern double Start_Lot_Size=0.1;//starting lot size for cycle
extern double Lot_Size_Increment=0.1;//Additional orders will increase by this amount
extern bool Long_Short_Balance=false;//will balance long and short order lots + add Balance_Weight if trend changes
extern double Balance_Weight=0.1;//amount over balanced long and short lot sizes you want to increase by with the trend
extern bool Double_Lotsize=false;//set to true if you want to just double every lotsize, Lot_Size_Increment ignored if true, will not work with weighted balance set to true
extern bool Choose_Own_Progression=false;//select true if you want te enter your own progression lot sizes below
extern double Trade_1=0;//Enter in your own trade progression lot sizes
extern double Trade_2=0;
extern double Trade_3=0;
extern double Trade_4=0;
extern double Trade_5=0;
extern double Trade_6=0;
extern double Trade_7=0;
extern double Trade_8=0;
extern double Trade_9=0;
extern double Trade_10=0;
extern double Trade_11=0;
extern double Trade_12=0;
extern double Trade_13=0;
extern double Trade_14=0;
extern double Trade_15=0;
extern double Trade_16=0;
extern double Trade_17=0;
extern double Trade_18=0;
extern double Trade_19=0;
extern double Trade_20=0;
extern int Max_Trades=20;//maximum number of trades allowed
extern bool Close_All_Max=false;//select true if you want ALL orders to close if Max_Trades is hit
extern bool Pyramid=true;//if true trades with trend, if false trades against trend
extern bool Auto_Restart=true;//set to true if you want EA to re-start after each cycle
extern bool Use_MA_Entry=false;//select true if you want moving average to decide starting direction
extern int Next_Trade=20;//next trade pip increment if Use_MA_Entry =true (will trade this many pips above OR below last order)
extern int MA_Period=7;//moving average period for calculation
extern int MA_Timeframe=60;//timeframe used for MA calculation, 1m=1, 5m=5, 15m=15, 30m=30, 1hr=60, 4hr=240, 1d=1440
extern bool Use_Kayvan_Method=true;//select to use kayvan's method
extern int Bar_Timeframe=60;//Bar Timeframe used to look back on, 1m=1, 5m=5, 15m=15, 30m=30, 1hr=60, 4hr=240, 1d=1440
extern int Bars_Look_Back=1;//number of bars looked back at from current bar for high and low
extern int EntryLag_Long=0;//number of pips above high to enter trade(ADD YOUR OWN SPREAD)
extern int EntryLag_Short=0;//number of pips below low to enter trade(ADD YOUR OWN SPREAD)
extern bool Last_Entry_Filter=false;//if true next high must be greater than last high, next low less than last low
extern bool Use_Trailing_Stop=true;//select true to use a trailing stop based on total $amount
extern double Trail_Start=10;//TS will start after this $Profit amount is reached
extern double TSLoss_Percent=50;//%Percentage of your HIGHEST profit you can lose before close all is performed
extern bool Close_By_Percent=false;//If true it will close by percent, if false it will close by Profit or Loss in $$
extern double TP_Percent=5;//will take profit if profit is greater than percent of account balance (close all orders)
extern double SL_Percent=10;//will stop loss if profit is less than percent of account balance (close all orders)
extern double Close_By_Profit=5;//close if >= to this $ amount
extern double Close_By_StopLoss=99999;//Amount of money to close all if lost
extern int Slippage=5;//slippage for ordersend command
extern int Number_Of_Tries=5;//Number of tries to send an OrderSend()command if not going through
extern bool Sound=true;//if true a sound will be played when an order goes through, and when a close all is performed
THIS IS STILL A WORK IN PROGRESS, STILL WORKING OUT ALL THE BUGS!
Latest version (v1_8) is posted below.
*This is a re-post of v1_8* Re-install from previous version. Newest posted 3/2/08