A simple expert advisor scanning multiple codes

MQL5 Asesores Expertos C++

Trabajo finalizado

Plazo de ejecución 4 días
Comentario del Cliente
Very helpful
Comentario del Ejecutor
Thanks! Nice customer.. hoping that we will work together again:)

Tarea técnica

I am very novice in programming a robot and I would like to develop the following EA. Overall the robot is looping continuously over a large number of symbols performing a few calculations on those symbols prices and deciding if it wants to buy or sell. I want no two open positions for the same symbol and also no position exchange (no positions should be closed to open new ones). For each open position of a symbol, the robot will need to find the buying price for that position and the day the position was opened as this is important information for determining the selling point.


I am not sure if one script can loop over several symbols (some users suggest that each tick function can only be employed on a single symbol). I am open to your suggestions (possibly copying pasting the code multiple times to scan various symbols or similar solution. I will need a couple of market days to test the code myself. See below for full annotation:



void OnTick()

  {

\\ Define a list of codes (approximately 500 codes in reality) to be checked. I have unsuccessfully tried defining an array and looping through those symbols. Possibly this is not the right solution (maybe you need to run OnTicks for each code separately. )

string symbol_array[]={"XOM","AAL","ABNB"};

int number_of_symbols=ArraySize(symbol_array);

Print("Total number of symbols is =",number_of_symbols);


for(int symbol_position=1;symbol_position<=number_of_symbols;symbol_position++)

{string stockname=symbol_array[symbol_position];

Print("Current symbol is =",stockname); 


\\ Do some simple calculations on the selected symbol, i.e. take its few last closing prices - No changes needed

double   Current_close = iClose(stockname,PERIOD_M1,0);

double   Close_minus1 = iClose(stockname,PERIOD_M1,1);

double   Close_minus2 = iClose(stockname,PERIOD_M1,2);

double   Close_minus3 = iClose(stockname,PERIOD_M1,3);

double   High_minus_1day = iHigh(stockname,PERIOD_D1,1);

double   High_minus_2day = iHigh(stockname,PERIOD_D1,2);

double   High_minus_3day = iHigh(stockname,PERIOD_D1,3);

double   High_minus_4day = iHigh(stockname,PERIOD_D1,4);

double   High_minus_5day = iHigh(stockname,PERIOD_D1,5);

double   High_minus_6day = iHigh(stockname,PERIOD_D1,6);

double   High_minus_7day = iHigh(stockname,PERIOD_D1,7);

double   High_minus_8day = iHigh(stockname,PERIOD_D1,8);


\\ Calculate a simple index of the trend pattern and also some local percentage changes and derivatives.  - No changes needed

double   Trending_pattern = (High_minus_4day+High_minus_3day+High_minus_2day+High_minus_1day) - (High_minus_8day+High_minus_7day+High_minus_6day+High_minus_5day);

double   Percentage_move3 = (Current_close-Close_minus3)/Close_minus3;

double   Percentage_move2 = (Current_close-Close_minus2)/Close_minus2;

double   Percentage_move1 = (Current_close-Close_minus1)/Close_minus1;

double   Local_derivative = Close_minus2/2 - 2*Close_minus1 +3*Current_close/2;


\\ Generate a buy signal IF Trending_pattern>0 && Local_derivative>0.05 && NO orders are pending for this code and NO positions are open for this code.

I do not want to exchange (close positions to open new ones) any currently open position. I do not know how to implement the 'NO orders should be pending and the 'NO open positions should exist for this code' parts. Please help me with this.

//buy signal

if ( Trending_pattern>0 && Local_derivative>0.05 && OrdersTotal()==0 )

{

   MqlTradeRequest request={0};

   MqlTradeResult  result={0};

//--- parameters of request

   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation

   request.symbol   =stockname;                              // symbol

   request.volume   =1;                                   // volume of 0.1 lot

   request.type     =ORDER_TYPE_BUY;                        // order type

   request.deviation=5;    


OrderSend(request,result);

}


\\ Generate a SELL signal IF 'the current selling price Current_close of an open position for the current code is 1.1 times the price I have bought it in the past' OR 'the position for this code was opened more than 3 days ago'.

I do not know how to implement either of these 2 conditions. Please help me with that.

//sell signal

if (Current_close >1.1*Price_paid_for_position)

{

   MqlTradeRequest request={0};

   MqlTradeResult  result={0};

//--- parameters of request

   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation

   request.symbol   =stockname;                              // symbol

   request.volume   =0.1;                                   // volume of 0.1 lot

   request.type     =ORDER_TYPE_SELL;                        // order type

   request.deviation=5;   

   

OrderSend(request,result);

}


\\ The above calculation has to loop over all codes included in the symbol_array string one by one for an indefinite amount of time.



Han respondido

1
Desarrollador 1
Evaluación
(57)
Proyectos
72
22%
Arbitraje
13
46% / 15%
Caducado
5
7%
Libre
2
Desarrollador 2
Evaluación
(58)
Proyectos
66
8%
Arbitraje
39
26% / 56%
Caducado
12
18%
Trabaja
Solicitudes similares
We are building a Python-based backend that integrates with a MetaTrader 5 Expert Advisor (EA) . The EA sends structured market data (pair, session, ATR, volume, previous highs/lows, etc.) to a FastAPI server , and the server responds with AI-driven trade recommendations and parameters . This backend will act as the “brain” of the EA , managing all decision logic, learning models, and data storage. This is a serious
I want to create a simple Expert Advisor for MT5 focused on XAU/USD scalping. Requirements: • Timeframe: M1 or M5 (auto-detect if possible) • Entry logic: follow trend using 2 Moving Averages (MA 9 and MA 50) • Buy when MA 9 crosses above MA 50 and candle closes above both • Sell when MA 9 crosses below MA 50 and candle closes below both • Lot size: 0.01 (customizable) • Take Profit: 10–15 pips (customizable) • Stop
I need an Expert Advisor (EA) for MetaTrader 4/5 based on ICT Smart Money Concepts. The EA should: - Detect Break of Structure (BOS), Fair Value Gaps (FVG), Order Blocks (OB), and Liquidity Sweeps. - Trade only during London and New York sessions. - Risk 0.5% of the account balance per trade. - Use TP/SL based on structure (1:2 RR minimum). - Include settings for Killzone times, BOS candle size filter, and alert
Hello everyone, I’m looking for a reliable and well-tested EA that can either pass prop firm challenges (such as FTMO, MyForexFunds, etc.) or show consistent long-term performance on a funded account. Requirements: Maximum drawdown: 1–2% per trade Adjustable lot size based on account size Solid risk management with on-chart panel (daily drawdown, equity, profit target, etc.) Proper Stop Loss and Take Profit logic —
Would it be possible to get a custom offer for creating a script that would draw trendlines for multiple timeframes both top and bottom of the candles, I would like the script to monitor the chart and provide me notification when the chart touches the trendline either top or bottom. If I have a position in the chart, the notification of provide me a notification of my position during each timeframe and well as when
NB! I NEED SOMEONE WHO WILL DO THE WORK FIRST AND THEN CREATE A BUILT-IN DEMO INDI AS PER SPECIFICATIONS BELOW WHICH HAS AN EXPIRY (A DAY OR 2) SO THAT I TEST THE INDI BEFORE WE CREATE THE ORDER. I HAVE HAD PEOPLE WHO PRESSURE ME TO CREATE THE ORDER AND THEN THEY END UP DEVELOPING A FAULTY INDICATOR. AND I HAVE GIVEN THEM THE BENEFIT OF THE DOUBT THROUGH ARBITRAGE AGREEMENTS. ALSO IT IS VERY URGENT I NEED THE DEMO
NB! I NEED SOMEONE WHO WILL DO THE WORK FIRST AND THEN CREATE A BUILT-IN DEMO INDI AS PER SPECIFICATIONS BELOW WHICH HAS AN EXPIRY (A DAY OR 2) SO THAT I TEST THE INDI BEFORE WE CREATE THE ORDER. I HAVE HAD PEOPLE WHO PRESSURE ME TO CREATE THE ORDER AND THEN THEY END UP DEVELOPING A FAULTY INDICATOR. AND I HAVE GIVEN THEM THE BENEFIT OF THE DOUBT THROUGH ARBITRAGE AGREEMENTS. ALSO IT IS VERY URGENT I NEED THE DEMO
NB! I NEED SOMEONE WHO WILL DO THE WORK FIRST AND THEN CREATE A BUILT-IN DEMO INDI AS PER SPECIFICATIONS BELOW WHICH HAS AN EXPIRY (A DAY OR 2) SO THAT I TEST THE INDI BEFORE WE CREATE THE ORDER. I HAVE HAD PEOPLE WHO PRESSURE ME TO CREATE THE ORDER AND THEN THEY END UP DEVELOPING A FAULTY INDICATOR. AND I HAVE GIVEN THEM THE BENEFIT OF THE DOUBT THROUGH ARBITRAGE AGREEMENTS. ALSO IT IS VERY URGENT I NEED THE DEMO
I need a trading bot 30 - 300 USD
I need an ai trading bot that trades automatically no need to set anything up should be fully automatic and work looking for a specific developer who applied please apply if you see this need this ai and to ask further questions about it thanks
im looking for a very high end robot that trades using ai and self optimization that learns and adapts to market conditions im looking for a specific developer but they canceled there application if you find this please apply im still interested and anyone else

Información sobre el proyecto

Presupuesto
44+ USD
Para el ejecutor
39.6 USD
Plazo límite de ejecución
de 1 a 3 día(s)