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

MQL5 Experts

Trabalho concluído

Tempo de execução 60 dias
Comentário do desenvolvedor
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 :)
Comentário do cliente
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.

Termos de Referência

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. 

Respondido

1
Desenvolvedor 1
Classificação
(69)
Projetos
93
34%
Arbitragem
10
40% / 30%
Expirado
5
5%
Livre
Pedidos semelhantes
Im looking for an coder to code an EA: Trade management 1. opening trades according to the indicator 2. trades settings to choose from like: open all trades according to the signal open only trade 1,2,3 or 4 % per trade ( example 50/30/20 of the lot settings, with 4 trades it would be for example 50/30/10/10) 3. SL/Trailing settings: Move SL to entry after hitting TP1/TP2 or TP3 moving SL by % keep the original SL
Hi I'm looking to have 2 of my pinescript strategies converted to MQL5 and was wondering if you could first give me a quote for the more simple strategy and then for both the simple and complex strategy together. The simple strategy is a MACD crossover type thing that uses a special EMA script that filters out some ranging price action and also fractal candles for the stop loss. The second strategy is market
I want grate robot for making profits that know when to start a good trade and close a trade and must be active all time to avoid lost of money
I have developed a very strong TradingView strategy in Pine Script but unfortunately, a third-party connector is requiired and in my opinion, I want a more direct connection. I am not brilliant at coding, but I have coded the majority of the MT5 code and I would like you to make sure that the MT5 code matches my TradingView script and executes the same way as the TradingView script that I will provide if you are
Mbeje fx 50+ USD
I like to own my robot that why I want to build my own.i like to be a best to every robot ever in the life to be have more money
I need an MT5 EA that can do the following: I have to give the EA a price in advance, when the price is reached the EA has to automatically place a buy stop or sell stop order 0.5 pips below or above the price. Is this possible
Dr Pattern 30+ USD
good day i need the service of the seaso coder to help me fix my ea The Job required 1 knowledge of Mt4 and Mt5 indicator coding 2. Telegram code 3. ability to code indicator to work on multiple Time frame combine to trade 4 Ability to Join two or three indicator on same ir different time frame if you have these skill please let chart i will discuss the details of the Job inside to you The required day including
Good day, I want someone to help me create a universal news filter with on/off switch, with start and end settings, and drawdown control with magic number of EAs, etc. Thanks
Hello, I am looking for a professional programmer to optimize my existing EA integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. i want it to be an EA that can be trusted to carry trade with the help of chat gpt and also have a very low drawdown
Hello, I am looking for a professional programmer to create a trading expert on the MT4 platform, integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. Further details will be provided to the applicants later

Informações sobre o projeto

Orçamento
60 - 100 USD
Desenvolvedor
54 - 90 USD
Prazo
de 1 para 7 dias