Specification
//+------------------------------------------------------------------+
//| SimpleMA.mq5 |
//| Auto trading bot example |
//+------------------------------------------------------------------+
#property copyright "ChatGPT"
#property link ""
#property version "1.00"
#property strict
input int FastMAPeriod = 10;
input int SlowMAPeriod = 30;
input double Lots = 0.1;
int fastMAHandle;
int slowMAHandle;
double fastMA[];
double slowMA[];
int OnInit()
{
// Create handles for moving averages
fastMAHandle = iMA(_Symbol, PERIOD_CURRENT, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
slowMAHandle = iMA(_Symbol, PERIOD_CURRENT, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
if(fastMAHandle == INVALID_HANDLE || slowMAHandle == INVALID_HANDLE)
{
Print("Failed to create indicator handles");
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
IndicatorRelease(fastMAHandle);
IndicatorRelease(slowMAHandle);
}
void OnTick()
{
// Copy data for the last 3 bars (to check crossover)
if(CopyBuffer(fastMAHandle, 0, 0, 3, fastMA) <= 0) return;
if(CopyBuffer(slowMAHandle, 0, 0, 3, slowMA) <= 0) return;
double fastPrev = fastMA[1];
double fastCurrent = fastMA[0];
double slowPrev = slowMA[1];
double slowCurrent = slowMA[0];
// Check if there is already an open position
int totalPositions = PositionsTotal();
bool buySignal = (fastPrev < slowPrev) && (fastCurrent > slowCurrent);
bool sellSignal = (fastPrev > slowPrev) && (fastCurrent < slowCurrent);
// Simple logic: if buy signal and no position, buy; if sell signal and no position, sell
if(buySignal)
{
if(!HasOpenPosition(ORDER_TYPE_BUY))
{
CloseOppositePositions(ORDER_TYPE_SELL);
OpenPosition(ORDER_TYPE_BUY);
}
}
else if(sellSignal)
{
if(!HasOpenPosition(ORDER_TYPE_SELL))
{
CloseOppositePositions(ORDER_TYPE_BUY);
OpenPosition(ORDER_TYPE_SELL);
}
}
}
// Check if there is an open position of a certain type
bool HasOpenPosition(ENUM_ORDER_TYPE orderType)
{
for(int i=0; i<PositionsTotal(); i++)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetInteger(POSITION_TYPE) == orderType)
return true;
}
}
return false;
}
// Close positions opposite to the current signal
void CloseOppositePositions(ENUM_ORDER_TYPE orderTypeToClose)
{
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetInteger(POSITION_TYPE) == orderTypeToClose)
ClosePosition(ticket);
}
}
}
// Open a market position (buy or sell)
void OpenPosition(ENUM_ORDER_TYPE orderType)
{
MqlTradeRequest request;
MqlTradeResult result;
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = Lots;
request.type = orderType;
request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.deviation = 10;
request.magic = 123456;
if(!OrderSend(request,result))
Print("Trade failed: ", GetLastError());
else
Print("Trade opened: ", orderType == ORDER_TYPE_BUY ? "BUY" : "SELL");
}
// Close position by ticket
void ClosePosition(ulong ticket)
{
MqlTradeRequest request;
MqlTradeResult result;
if(!PositionSelectByTicket(ticket))
{
Print("Position not found: ", ticket);
return;
}
double volume = PositionGetDouble(POSITION_VOLUME);
ENUM_POSITION_TYPE type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
double price = (type == POSITION_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_BID) : SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.action = TRADE_ACTION_DEAL;
request.position = ticket;
request.symbol = _Symbol;
request.volume = volume;
request.type = (type == POSITION_TYPE_BUY) ? ORDER_TYPE_SELL : ORDER_TYPE_BUY;
request.price = price;
request.deviation = 10;
request.magic = 123456;
if(!OrderSend(request,result))
Print("Close failed: ", GetLastError());
else
Print("Position closed: ", ticket);
}
//| SimpleMA.mq5 |
//| Auto trading bot example |
//+------------------------------------------------------------------+
#property copyright "ChatGPT"
#property link ""
#property version "1.00"
#property strict
input int FastMAPeriod = 10;
input int SlowMAPeriod = 30;
input double Lots = 0.1;
int fastMAHandle;
int slowMAHandle;
double fastMA[];
double slowMA[];
int OnInit()
{
// Create handles for moving averages
fastMAHandle = iMA(_Symbol, PERIOD_CURRENT, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
slowMAHandle = iMA(_Symbol, PERIOD_CURRENT, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
if(fastMAHandle == INVALID_HANDLE || slowMAHandle == INVALID_HANDLE)
{
Print("Failed to create indicator handles");
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
IndicatorRelease(fastMAHandle);
IndicatorRelease(slowMAHandle);
}
void OnTick()
{
// Copy data for the last 3 bars (to check crossover)
if(CopyBuffer(fastMAHandle, 0, 0, 3, fastMA) <= 0) return;
if(CopyBuffer(slowMAHandle, 0, 0, 3, slowMA) <= 0) return;
double fastPrev = fastMA[1];
double fastCurrent = fastMA[0];
double slowPrev = slowMA[1];
double slowCurrent = slowMA[0];
// Check if there is already an open position
int totalPositions = PositionsTotal();
bool buySignal = (fastPrev < slowPrev) && (fastCurrent > slowCurrent);
bool sellSignal = (fastPrev > slowPrev) && (fastCurrent < slowCurrent);
// Simple logic: if buy signal and no position, buy; if sell signal and no position, sell
if(buySignal)
{
if(!HasOpenPosition(ORDER_TYPE_BUY))
{
CloseOppositePositions(ORDER_TYPE_SELL);
OpenPosition(ORDER_TYPE_BUY);
}
}
else if(sellSignal)
{
if(!HasOpenPosition(ORDER_TYPE_SELL))
{
CloseOppositePositions(ORDER_TYPE_BUY);
OpenPosition(ORDER_TYPE_SELL);
}
}
}
// Check if there is an open position of a certain type
bool HasOpenPosition(ENUM_ORDER_TYPE orderType)
{
for(int i=0; i<PositionsTotal(); i++)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetInteger(POSITION_TYPE) == orderType)
return true;
}
}
return false;
}
// Close positions opposite to the current signal
void CloseOppositePositions(ENUM_ORDER_TYPE orderTypeToClose)
{
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetInteger(POSITION_TYPE) == orderTypeToClose)
ClosePosition(ticket);
}
}
}
// Open a market position (buy or sell)
void OpenPosition(ENUM_ORDER_TYPE orderType)
{
MqlTradeRequest request;
MqlTradeResult result;
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = Lots;
request.type = orderType;
request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.deviation = 10;
request.magic = 123456;
if(!OrderSend(request,result))
Print("Trade failed: ", GetLastError());
else
Print("Trade opened: ", orderType == ORDER_TYPE_BUY ? "BUY" : "SELL");
}
// Close position by ticket
void ClosePosition(ulong ticket)
{
MqlTradeRequest request;
MqlTradeResult result;
if(!PositionSelectByTicket(ticket))
{
Print("Position not found: ", ticket);
return;
}
double volume = PositionGetDouble(POSITION_VOLUME);
ENUM_POSITION_TYPE type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
double price = (type == POSITION_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_BID) : SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.action = TRADE_ACTION_DEAL;
request.position = ticket;
request.symbol = _Symbol;
request.volume = volume;
request.type = (type == POSITION_TYPE_BUY) ? ORDER_TYPE_SELL : ORDER_TYPE_BUY;
request.price = price;
request.deviation = 10;
request.magic = 123456;
if(!OrderSend(request,result))
Print("Close failed: ", GetLastError());
else
Print("Position closed: ", ticket);
}
Responded
1
Rating
Projects
341
71%
Arbitration
12
42%
/
25%
Overdue
12
4%
Free
Published: 17 codes
2
Rating
Projects
73
21%
Arbitration
11
18%
/
27%
Overdue
6
8%
Working
3
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
4
Rating
Projects
5
20%
Arbitration
0
Overdue
0
Working
5
Rating
Projects
3
0%
Arbitration
0
Overdue
0
Busy
6
Rating
Projects
115
70%
Arbitration
5
80%
/
0%
Overdue
11
10%
Free
7
Rating
Projects
6
17%
Arbitration
2
0%
/
0%
Overdue
1
17%
Loaded
8
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Similar orders
Automate my strategy
150+ USD
My Strategy is very simple yet complex. I require a strong coder to be available to be able to code this and have a vast and deep understanding of the market. I require this to be automated and will give more details once I have matched with someone. Furthermore, I would prefer if we could exchange numbers just so it is easier to converse with the person. Thank you
Hello, I would like to develop a custom Expert Advisor (EA) for MT4 (or MT5 if preferred). Requirements: Open trades based on a signal (to be specified later: e.g., indicator, moving average cross, or manual conditions). Automatically set Stop Loss (SL) and Take Profit (TP) for each trade. Option to open an averaging/hedging trade with the same lot size when the price moves against the first trade by a defined number
Hello, I’m looking for an MQL5 or MQL4 EA that trades EURUSD (optionally other majors or XAUUSD). The broker applies a 4-pip spread on EURUSD and higher on other symbols. The sole objective is to generate at least 45–60 lots of volume within 2 weeks or max one month (more is better; a bonus is paid for every additional 10 lots traded). The account has 1000 USD starting balance. Capital preservation is not required
Quantconnect developer to build trading strategy
100 - 150 USD
I need help building a successful trading strategy on QuantConnect. The goal is to achieve a sharp ratio greater than 2 and returns above 100% per annum, with the strategy scripted and backtested on the platform. Scope of work - Develop a trading strategy with a sharp ratio greater than Ensure returns exceed 100% annually. - Draft and backtest the strategy using QuantConnect platform. Additional information Build &
Profitable MT4 EA suitable for prop firms
30 - 100 USD
I am looking for an experience MQL4 developer for making a profitable prop firm compatible MT4 gold scalper EA on a 5 Minute time frame. The EA should have a win rate of not less than 90% on back testing. The EA should be able to pass all prop firm challenges like Funded Next, FTMO, Funding Pips within 1-2 weeks. The EA should also work on live funded account. Any strategy can be used to develop the EA. Proper risk
Modify my MT5 EA
30 - 40 USD
I am looking for an MQL5 programmer who can modify and customize my personal MT5 EA. There is problem in placing stop loss but still the EA is profitable on back testing. I also want to add news filter and prop firm compatible. The details will be shared to the developer personally
Breakout and Retest/Supply and Demand Strategies for EA Expert Advisors, on MQL5 1. *Breakout Strategy*: Identify key levels of support/resistance and enter trades upon breakout. 2. *Retest Strategy*: Wait for price to retest previously broken levels before entering trades. 3. *Supply and Demand Strategy*: Identify areas of strong buying/selling interest (supply/demand zones). *Best Practices* 1. Define clear
Sime martingle ea
50+ USD
I need a simple zone recovery martingle ea which buys when the zone breaks upwards and sells welhencthe zone breaks downwards no indicator nothing simple inputs pannel with martingle multiplier zone size +tp size -tp size number no martingle allowed and starting pip size
Conversion of Trading Plan into EA
50 - 150 USD
I need MQL4 EA for a forex expert advisor to trade on MT4 that uses a reversal strategy with the following conditions: only pairs that will enter are USDJPY, EURJPY, CADJPY, NZDJPY, AUDJPY, GBPJPY, CHFJPY. Each pair can only be traded once a month. Will only enter the market on 1 hour timeframe. Lot size = 1.0. Risk:reward ratio is 1:2. Enter if there are at least 7 confirmations from the following signals: for the
Bainanans
500+ USD
Bainanan good f المؤشر. ينبغي إضافة نقطة صفراء عند أعلى نقطة في الشموع في منطقة ذروة الشراء - وهي نقطة H. ينبغي إضافة نقطة خضراء عند النقطة المنخفضة للشموع في منطقة ذروة البيع - وهي نقطة L. إذا وُجدت نقطة L واحدة على الأقل بين نقطتي H، فابحث عن نقطة LL في الفترة الفاصلة بينهما. ستكون الشمعة ذات أدنى سعر قاع هي نقطة LL. بشكل عام، لا تُعتبر نقطة LL بالضرورة نقطة L. ابحث عن الشموع ذات أدنى سعر قاع. إذا كانت هناك نقطة H
Project information
Budget
30 - 1000 USD
Deadline
from 1 to 7 day(s)
Customer
Placed orders1
Arbitrage count0