Specifiche

//+------------------------------------------------------------------+
//| 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);
}

Con risposta

1
Sviluppatore 1
Valutazioni
(254)
Progetti
341
71%
Arbitraggio
12
42% / 25%
In ritardo
12
4%
Gratuito
Pubblicati: 17 codici
2
Sviluppatore 2
Valutazioni
(50)
Progetti
73
21%
Arbitraggio
11
18% / 27%
In ritardo
6
8%
In elaborazione
3
Sviluppatore 3
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
4
Sviluppatore 4
Valutazioni
(5)
Progetti
5
20%
Arbitraggio
0
In ritardo
0
In elaborazione
5
Sviluppatore 5
Valutazioni
(3)
Progetti
3
0%
Arbitraggio
0
In ritardo
0
Occupato
6
Sviluppatore 6
Valutazioni
(84)
Progetti
115
70%
Arbitraggio
5
80% / 0%
In ritardo
11
10%
Gratuito
7
Sviluppatore 7
Valutazioni
(6)
Progetti
6
17%
Arbitraggio
2
0% / 0%
In ritardo
1
17%
Caricato
8
Sviluppatore 8
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Ordini simili
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
the robot i want to program is very simple easy strategy i use to make profit every day. the strategy is based on two MA and RSI the robot must work in forex paairs Gold, and futures, ill pay 40 dlls i will give more detail once we are connected
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
Automate my strategy 30 - 70 USD
🚀 Looking for a Trading Bot Coder 🚀 I’m searching for an experienced developer to help automate my trading strategies. Requirements: Strong knowledge in MQL5 / MT5 (or TradingView Pine Script, depending on platform) Experience with price action & strategy automation Ability to integrate custom risk management & alerts 💡 If you’re a skilled coder who can turn trading ideas into a profitable bot, let’s connect
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
Hey there, I’m looking to get a custom NinjaTrader indicator/plugin/tool developed. It’s very similar to Riley Coleman’s “Candlestick Trader” indicator (you can see a walkthrough of it in this YouTube video at timestamp 6:52: https://www.youtube.com/watch?v=NjCUZveXtLo&amp ;t=303s ). Please take a look at that video for reference, as I’d like most of the core features replicated. To summarize, the key functions I
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
I’m looking for a profitable Expert Advisor (EA) — the real beast that can deliver strong results on MT4/MT5. If you have a proven EA with good performance and risk management, kindly reach out with details and results
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
Hi, I am looking for readymade EA/a developer who can build it one for me. Feel free to contact me if you can fulfill my requirement. But be sure my a developer must have capability to develop complex EA with robust architecture. Especially on sophisticated trading methodology i.e. ICT/SMC etc

Informazioni sul progetto

Budget
30 - 1000 USD
Scadenze
da 1 a 7 giorno(i)

Cliente

Ordini effettuati1
Numero di arbitraggi0