EA to switch between 2 symbols according to trading parameters (with code for MT4 & MT5)

MQL5 Experts

Tâche terminée

Temps d'exécution 60 jours
Commentaires de l'employé
Even we done this project in a long time, I am grateful for great ideas and nice communication. I hope catch his future jobs too :)
Commentaires du client
Mohammad is BY FAR the most talented programmer I hired so far. He contributed with original solutions to problems that had long troubled me. Great communication, definitely a long-term partnership.

Spécifications

GENERAL IDEA
-- we specify 2 symbols (ex. input symbol 1 = Microsoft & symbol 2 = Apple);

-- we specify input initial amount to trade (ex. $10,000);

-- we specify the interval at which the EA will check the trading conditions (ex. input interval_X = 10M)

-- we specify the trading parameters (ex. input conditions X = 1.0%; & Y = 1.5%)

ACTIONS:

1) UNIQUE ACTION = FIRST BUY:

-- if there is no open position by this EA, immediately buy X shares (= lot1) of symbol 1 at current ask_price (using the initial amount to calculate the lot);

-- register the quotes of BOTH symbol_1 & symbol_2 at the time of the transaction (let's call the "LAST-TRADE-QUOTE-1 & LAST-TRADE-QUOTE-2): those values will be used for trading condition X.


2) REGULAR/REPEATED ACTIONS: (obs. after the first buy, there'll always be an open position)

at every interval_X, check which symbol is the current open position;
-- if symbol 1 is current position, check if condition_X or condition_Y is true
  -- if symbol 1 is current position & (X or Y is true) --> sell symbol 1 

-- use the money from the sell to calculate lot2 (# of shares) --> buy  symbol 2

-- register quotes of both symbols (last-trade-quote-1 & last-trade-quote-2);


-- if symbol 2 is current position, check if condition_X or condition_Y is true
-- if symbol 2 is current position & (X or Y is true) --> sell symbol 2

-- use the money from the sell to calculate the new lot1 (# of shares) --> buy  symbol 1;

-- register quotes of both symbols (last-trade-quote-1 & last-trade-quote-2);

Bottom line:

-- after the first buy, there will always be an open position;

-- the EA will check the trading conditions: if they are true, sell symbol 1 & buy symbol 2 (or sell symbol 2 & buy symbol 1);

-- repeat the process at the defined interval

==============

GENERAL IDEA WITH MORE DETAILS: 

An important part of this EA is the "dynamic calculation" of the lots, meaning: after we close a position, the money generated by the sell of symbol_1 (or symbol_2) will be used to calculate how many shares we can buy of symbol_2 (or symbol_1). 

I think this can be achieved with the use of the following variables: 

double BUYMONEY (the available money to make the buy), SELLMONEY (the money generated by the sell), STANDBYCASH (the money not used in the buy after rounding down to min-lot). 

As there is a MIN LOT requirement, we never use the total amount of available money. We'll call this the STANDBYCASH. 


1) calculating the STANDBYCASH
let's say we have 10,000 to start with and Microsoft is $98. 
let's say the MIN-LOT = 1.0. 
so we could buy 102 shares of Microsoft. 
now: 102 lots at $98 = $9,996, which means that $4 are not used: that's the standbycash = $4
so standbycash = previous available money to make a buy (or BUYMONEY) - amount spent in the buy (which can be calculate by lot * ask.price). 

2) so, after the first buy, we will (always) have an open position.
let's say the trading conditions are true, so it's time to sell. 
let's say the bid price for Microsoft is $104. 
the amount generated by this sell (SELLMONEY) = lot1 * bid1 = 102 * 104 = $10,608 
so the new total amount available to make a buy (let's call it BUYMONEY = standbycash ($4) + sellmoney ($10,608) = $10,612
{obs. later on we can also include TRADEFEES: buymoney = standbycash + sellmoney - tradefees}
With that, we can calculate LOT2 (the # of shares of symbol_2 to be bought): 
LOT2 = buymoney / ask2 (the ask price of symbol2) (rounding to min lot). 
Let's say the ask_price of Apple is $84. 
With $10,612 we could buy 126 shares of Apple. 
Now, 126 * 84 = 10,584 meaning that we will have $28 left in the account. 
new standbycash = 10,612 - 10,584 = $28

Next time, we will sell Apple, say, at 90.

126 shares * 90 = $11,340 (sellmoney)
new buymoney = sellmoney + standbycash = 11,340 + 28 = $11,368

With that, we calculate the new lot of Microsoft to buy.
Let's say Microsoft is now $112.
With $11,364 at $112, we can buy 101 Microsoft (always rounding to min lot). 
Amount spent = 101*112 = $11,312, meaning the new standbycash = 11,364 - 11,312 = $52

And so on.

=========================

SPECIFICATIONS ABOUT THE CONDITIONS X & Y

input periods = 50;

input condition_X = 1.0%
input condition_Y = 1.5%

X1 = (bid1 / last-trade-quote-1) - (ask2 / last-trade-quote-2);  // X1 is the condition X when symbol_1 is the current/open position
X2 = (bid2 / last-trade-quote-2) - (ask1 / last-trade-quote-1); // X2 is the condition X when symbol_2 is the current/open position

Y1 = bid1 / avg1 (= average of 50 periods of symbol1) - ask2 / avg2   // Y1 is the condition Y when symbol_1 is the current/open position
Y2 = bid2 / avg2 (= average of 50 periods of symbol2) - ask1 / avg1  // Y2 is the condition Y when symbol_1 is the current/open position

if (X1 >= condition_X || Y1>= condition_Y) bool sell_1_buy_2 is true
if (X2 >= condition_X || Y2>= condition_Y) bool sell_2_buy_1 is true

===========================

Thanks

Marcos

PS. $100 is the budget for having the EA with the code for both MT4 & MT5

PS2. I have developed this myself and works well in the strategy tester, but I want/need it to be protected against potential errors.

So, the developer who accepts the job may either revise/adapt/protect the code I already have or create his own. 

Répondu

1
Développeur 1
Évaluation
(69)
Projets
93
34%
Arbitrage
10
40% / 30%
En retard
5
5%
Gratuit
Commandes similaires
I am developing a master EA that integrates several sub-EAs. The project is complex, and the documentation is thoroughly structured, spanning 50 pages with detailed step-by-step procedures. 1st sub-EA: This EA opens trades without using indicators. Instead, it opens a new trade based on the color or status of the last candle. For instance, if the last candle was green, a new buy trade is opened. 2nd sub-EA: This EA
Good Day I would like to order a trading robot. Pairs: XAUUSD (GOLD) EUR/USD USD/JPY The robot should be trading daily with TP/SL build in, would like to have trailing and stop loss, should execute up to 5 trades (preffarable setting choice) up to 10 trades Los sizes to be choise setting, must also trade major US vews events Like:US- PPI, CPI, NFP, Sales m/m and so on Must also show/display alert when opening
Hello Guys, I need a trading bot for the MT5 to place order based on my trading strategy which is based on - >> entry based on EMA with rejection from specific levels like support and resistance area - levels and time frame i will apply into the robot manually on daily basis. also need - trailing stoploss , shift to breakeven after gaining some points. need a highly expert developer
Trade Manger EA 30+ USD
Hello Programmer! I am looking to build an EA that will place my trade and manage it. Once i have manually found my setup, I will want an EA to open the trade, set the R:R and manage it according to my specifications. please take a look at the attached to get an Idea of what I would like. I will require the source code once completed
Hello there i need someone who will create a robot that will calculate the movement between buy/sell and show where to take profit the robot should work with all currency and indices including stock
EA to send account history to web request. It should send every 5 mins or when there is an update. It then sends the json to a web request where gain, drawdown, balance, equity will be displayed
I have a full strategy based on indicator and candle based on . i would like to make it into a robot which will trade for me on a specific time and specific rules. i need a person who can do this project for me. If you have done this type of job . you are most welcome for this. Apply only if you know binary trading option and binomo trading platform well and how it works
Preciso de um EA, que faça o fecho automático de operações abertas no final da sessão e nas notícias de alto impacto. Um EA simples com apenas 1 função. Fecho das operações abertas
Enter buy trade at close of candle when bar closes above the 3 emas. Emas are 34 ema, 64 ema and 128 ema. For a buy trade the 34 ema must be above the other two emas. The 64 ema should be in the middle. The 128 ema should be below the other two emas. For a buy trade the Awesome Oscillator should be above the middle line and colored green. Exit a buy trade when price touches 64 ema. Sell trade same conditions as buy
I want to make AI based on Attached Picture Swing High low. If you have experience can share demo first. Stop loss, take profit, trailing , break even ,DD etc. also amiable

Informations sur le projet

Budget
60 - 100 USD
Pour le développeur
54 - 90 USD
Délais
de 1 à 7 jour(s)