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.
Solicitudes similares
Specification 1. Objective To acquire or develop a technological solution that allows the generation of temporary “FLASH” USDT on the TRON (TRC20) network, with an on-chain lifespan equal to or greater than 180 days . 2. Functional Scope 2.1 FLASH USDT Generation Creation of temporary USDT tokens visible on the TRON TRC20 blockchain. Minimum lifespan: 180 days (or higher, depending on configuration). 2.2
I am looking for an experienced trading software developer interested in building a long-term working relationship. Im a professional Trader, Coach and Mentor, I work with traders and Student who require customized trading solutions, including automated trading bots, Expert Advisors, custom indicators, trading strategies and other algorithmic trading tools. I am looking for a technically skilled developer who can
I am looking for an experienced MQL5 developer to recreate my existing MT5 Expert Advisor (DSTR Novaa). I have the original compiled EX5 file, Vantage MT5 live trading history and original Strategy Tester report. Required Trading Logic: EMA Period: 3. BUY when price crosses below EMA 3. SELL when price crosses above EMA 3. Starting Lot: 0.01 (configurable). Martingale Multiplier: 2.0. Maximum Martingale Cycle: 9
Hello, I need a high-quality, reliable, and well-coded Expert Advisor (EA) for MetaTrader 5. The code must be clean, without errors, and optimized for safe trading. The robot needs to trade based on basic technical indicators. Every trade must have a strict Stop Loss and Take Profit for risk management. Please apply only if you are an experienced MT5 developer with a high rating and clean coding history. Best
I need an EA for MetaTrader 5 called AI Forex Robot V100. It must trade automatically on EURUSD and GBPUSD, M15 timeframe. Strategy: - Buy when fast EMA crosses above slow EMA and RSI is above 50 - Sell when fast EMA crosses below slow EMA and RSI is below 50 - Only 1 trade at a time - Stop Loss: 50 pips, Take Profit: 100 pips - Lot size: 0.01, with option to change in settings - Must have trailing stop and news
PROJECT: EXISTING MT5 EA MODIFICATION – XAUUSD SLIPPAGE REDUCTION 1. Project Objective I already have a fully developed MT5 Expert Advisor (.mq5 source code). I am looking for an experienced MQL5 developer who can optimize my existing EA to achieve the lowest possible execution slippage on a REAL LIVE trading account. My primary and only objective is to zero slippage. I am not looking for a new trading strategy or
ثبت طلبك في مواصفات البوت الثاني كذا: الجودة والأمان أهم من السعر، وما يدخل إلا إذا الفرصة قوية، مع حماية عند الخسائر وانقطاع الاتصال وارتفاع السبريد، وتشغيل مستمر على سيرفر، مع اختبارات إلزامية قبل أي تشغيل حقيقي. بهذه الصيغة يصير يشتغل وأنت مرتاح بالِك، لكنه يوقف تلقائيًا وقت عطلة السوق أو أي خلل. بس أكون واضح معك: ما في بوت يضمن عدم الخسارة، خصوصًا بالمضاربات السريعة، هدفنا نقلل المخاطر ونمنع الخسائر غير المنضبطة
I'm looking for an experienced MQL5 developer to create a Opening Range Breakout EA. The EA should identify the high and low of a configurable trading session and open trades when price breaks out of this range. It should include configurable Stop Loss, Take Profit, fixed lot size, break-even option and trading hours. Full mq5 required
1. Project Overview I am seeking an experienced MQL4 programmer to develop a fully automated, adaptive, and profitable Expert Advisor (EA) specifically designed for trading Gold (XAUUSD) on the MetaTrader 4 (MT4) trading platform. The objective is to develop a high-frequency scalping EA capable of identifying and executing high-probability trading opportunities across changing market conditions, including trending
#property strict #property version "1.00" #property description "EMA Trend + Pullback + Engulfing EA" // Include the standard MT5 trade library. #include <Trade/Trade.mqh> CTrade trade; //============================================================== // INPUT SETTINGS //============================================================== // Trend indicators input int FastEMA = 20; input int SlowEMA = 50; // Pullback