Job finished
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Specification
I want an EA with 5 magic numbers to operate 5 eas at same time. The EA design will be modular using 5 signals on on EA1 (basket 1). The SIGNALS OF BASKET 1 will not be used by other baskets( OTHER BASKETS EA2,EA3,EA4,EA5).
The new signal on basket1 EA will be recorded by EA as NEWSIGNAL=1, PRICE 22000. The entry price of new signal will be recorded, it will be used by EA2 (BASKET2), EA3(BASKET3),EA4 (BASKET4), EA5(BASKET5),
If all baskets are closed , EA will record NEWSIGNAL=0 // ALL OPEN TRADES ARE CLOSED
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The SIGNALS BASKET 1 EA1: There are five potential entries on basket1/EA1
Basket1/EA1` will have option to start with signals.only basket1 EA1 uses signals.
entry signal 1;input double basket1 buy =22000; /first trade level is for buys basket 1// if there is input (22000) , signals are disabled
entry signal 2 Trade open time basket 1 ;8 am at market (close 07.59 bar)//only applies to basket1 //signal to open trade basket 1 if no trades are open .
signals 3,4 ,5 are attached
entry signal 3;input bool UseSignal3=false;
entry signal 4;input bool UseSignal4=false;
entry signal 5;input bool UseSignal5=false;
USE MARKET ORDER FOR SIGNALS
if signals are triggered, but if there are open trades on any basket (new signals will be disabled)
input double basket1 buy =22000; /first trade level is for buys basket 1
input double basket1 sell =0;//first trade is not valid this is for sells 0 basket 1 sell level
input type of trade basket 1= buy ; //first trade is a buy...............if sell sell//input is for BASKET 1 TRADE 1 :buy
BASKET 1 MAGIC NUMBER IS MAGIC NUMBER + 1 =25501
BASKET 1 TRADE 1 The first trade is a buy , open first trade as a buy.MARKET ORDER
The SIGNALS BASKET 1 EA1//END
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The SIGNALS for BASKET 2 EA2, BASKET 3 EA3, BASKET 4 EA4, BASKET 5 EA5
SIGNALBASKET 2 EA2: distance from NEWSIGNAL=1 = NEWSIGNAL +500 , If NEWSIGNAL is 22,000 , entry price for EA2 is 22,500
input type of trade basket 2 EA2 =sell ; //first trade is a sell
multi reversal basket2 = true; input int TakeProfitbasket2=1500; input int StopLossbasket2=750; input int MagicNumber=25502;
SIGNALBASKET 3 EA3: distance from NEWSIGNAL=1 = NEWSIGNAL -500 , If NEWSIGNAL is 22,000 , entry price for EA3 is 21,500
multi reversal basket3 = true;
input int TakeProfitbasket3=2500;
input int StopLossbasket3=2750; input int MagicNumber=25503;
1nput type of trade basket 3 EA3 =sell ; //first trade is a sell
SIGNALBASKET 4 EA4: distance from NEWSIGNAL=1 = NEWSIGNAL +1500 , If NEWSIGNAL is 22,000 , entry price for EA4 is 23,500
input type of trade basket 4 EA4 =buy ; //first trade is a buy
multi reversal basket4 = true; input int TakeProfitbasket4=11500; input int StopLossbasket4=7150; input int MagicNumber=25504;
SIGNALBASKET 5 EA5: distance from NEWSIGNAL=1 = NEWSIGNAL -1500 , If NEWSIGNAL is 22,000 , entry price for EA5 is 20,500
multi reversal basket5 = true; input int TakeProfitbasket5=11500; input int StopLossbasket5=1750; input type of trade basket 5= buy ; //first trade is buy input int MagicNumber=25505; END//The SIGNALS for BASKET 2 EA2, BASKET 3 EA3, BASKET 4 EA4, BASKET 5 EA5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Friday close all on friday applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
Close all FRIDAY= true;
input string new basket FridayCloseTime="19:00";// no new baskets opened after friday at 19:00. applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
input string new basket StartOnMonday="01:00";//StartOnMondaytime applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
input int MagicNumber=25500;// main magic will log newsignals for basket1 EA1
starting lot size: input double starting LotSize=0.1;// starting lot size if no martingale, use starting lot size applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
Basket profit (basket profits is in pips)// all baskets pips are in profit
FUNCTION:saftey checks applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
stop loss , pending order and take profit entry checker// ea will check every 5 minutes for missing entries , if missed by platform
MAXIMUM OPEN:maximum open trades per basket:Only 1 actual trade + 1 pending trade// each basket =2 applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
COMMENT:input string AddToComment="multireversal";
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
multi reversal basket ( applies to all 5 EAS EA1, EA2,EA3,EA4,EA5)
Code this as a function, so it can later be used for EA1, EA2,EA3,EA4,EA5
I want an ea to place an order at fixed start price of 22000 .It will place a stop loss and profit target .
input int TakeProfitbasket1=2000;//take profit basket1
input int StopLossbasket1=1000; // stop loss basket 1
all baskets EA1, EA2,EA3,EA4,EA 5function like this basket
When the buy trade is opened , at trade open time basket 1 , ea will place an opposite trade at stop loss level.Opposite trade will be a sell.TRADE 2
Example buy trade is opened at 22000, open pending sell trade at 21000 (stop loss level).
If take profit is hit , delete pending order .reset trade to trade 1 if take profit is hit
If take profit is not hit , the pending order will be hit it will be sell.TRADE 2
When TRADE 2 is opened, pending TRADE 3 is opened at stop loss level.
If take profit is achieved , reset trade to trade 1, otherwise place reversal trades as follows
BASKET 1 TRADE 1 :buy level 22000
BASKET 1 TRADE 2:sell level 21000
BASKET 1 TRADE 3 :buy level 22000
BASKET 1 TRADE 4:sell level 21000
BASKET 1 TRADE 5 :buy level 22000
BASKET 1 TRADE 6:sell level 21000
BASKET 1 TRADE 7 :buy level 22000
BASKET 1 TRADE 8:sell level 21000
continue trade 9,10,11,12 etc until take profit is hit or trade is closed by other take profit
Always reset trade to trade 1 every time if take profit is hit
multi reversal basket1 //end..............
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:reinstate trade = true; // applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
input double reinstate trade = true;//If basket is closed at a profit,in the above trades,if no trade is open for basket , and price comes back to entry price of basket trade1 , reinstate trade at
/first trade level //enter a market order .In order to re-instate trade from any basket , basket 1 must be open.
reinstate trade1 basket1 = true;//If basket is closed at a profit
reinstate trade1 basket2 = true;//If basket is closed at a profit
reinstate trade1 basket3 = true;//If basket is closed at a profit
reinstate trade1 basket4 = true;//If basket is closed at a profit
reinstate trade1 basket5 = true;//If basket is closed at a profit
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Function Martingale //applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
input bool UseMartingale=true;
if use martingale= true; // use different position sizes or otherwise use starting lot size
different positions sizes for each reversal trade based on losses sequence 0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4 etc as follows
If take profit is achieved , reset trades to trade 1,
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close all day profit= true;//applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
Close all day profit= 50.00; if account balance has risen by £50.00 since open at 0.01 today//close all baskets
If Close all day profit take profit is achieved , reset trades to trade 1,
State on dashboard open price today
close all basket1,2,3,4,5 = true;//close all basket1,2,3,4,5 day profit
close all 5 magic numbers
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close single basket profit6789=true; //close trades of basket with 6 , 7 , 8 or 9 trades at level //applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
If take profit is achieved , reset trade to trade 1
if BASKET TRADE 6 is open and trade profit is 150 pips //reset to trade 1 if target achieved
if BASKET TRADE 7 is open and trade profit is 150 pips //reset to trade 1 if target achieved
if BASKET TRADE 8 is open and trade profit is 150 pips //reset to trade 1 if target achieved
if BASKET TRADE 9 is open and trade profit is 150 pips //reset to trade 1 if target achieved
If Close all Close single basket profit6789 take profit is achieved , reset trades to trade 1,
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close all weekly profit= true;//applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
Close all weekly profit= 50.00; if account balance has risen by £50.00 since open at 0.01 monday//close all baskets
Close all weekly day= friday;
If Close all weekly profit take profit is achieved , reset trades to trade 1,
close all weekly basket1,2,3,4,5 = true;//close all weekly basket1,2,3,4,5 weekly profit
State on dashboard open price of week
close all 5 magic numbers
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close all = true;// close all manual switch
If Close all is activated , reset trades to trade 1,
close all basket1 = true;//close all basket1
close all basket2 = true;//close all basket2
close all basket3 = true;//close all basket3
close all basket4 = true;//close all basket4
close all basket5 = true;//close all basket5
close all basket1,2,3,4,5 = true;//close all basket1,2,3,4,5
close all 5 magic numbers
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close all if slippage greater than 500 //applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
If any trade is missed out, slippage between entry price and actual price , when market opens, in any basket , close all baskets after 5 minutes.
close all basket1,2,3,4,5 = true;//close all basket1,2,3,4,5
close all 5 magic numbers
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Close all if any basket is not equal to two or zero trades .//applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.
if any basket is not equal to or zero trades or two trades , close only current basket after 5 minutes
If Close all is activated , reset trades to trade 1,
close all basket1 = true;//close all basket1 not 0 or 2
close all basket2 = true;//close all basket2 not 0 or 2
close all basket3 = true;//close all basket3 not 0 or 2
close all basket4 = true;//close all basket4 not 0 or 2
close all basket5 = true;//close all basket5 not 0 or 2
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FUNCTION:Profit manager as below //applies to all 5 EAS EA1, EA2,EA3,EA4,EA5.