EA der bei Kreuzung von 2 EMAs - eine Long und eine Short Position eröffnet. Das darf er bei Kreuzung aber nur einmal machen, bis ich die Pos. geschlossen habe. EMAs müssen veränderbar werden können.

MQL5 Experts

Termos de Referência

mql4
//+------------------------------------------------------------------+
//|                                                      MA_Cross.mq4|
//|                        Copyright 2024, MetaQuotes Software Corp. |
//|                                       https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
input int fastMA = 12; // Periode des schnellen MA
input int slowMA = 25; // Periode des langsamen MA
input double lotSize = 0.01; // Lotgröße

double fastMAValue, slowMAValue;
bool positionOpen = false;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   fastMAValue = iMA(NULL, 0, fastMA, 0, MODE_SMA, PRICE_CLOSE, 0);
   slowMAValue = iMA(NULL, 0, slowMA, 0, MODE_SMA, PRICE_CLOSE, 0);
   double fastMAValuePrev = iMA(NULL, 0, fastMA, 0, MODE_SMA, PRICE_CLOSE, 1);
   double slowMAValuePrev = iMA(NULL, 0, slowMA, 0, MODE_SMA, PRICE_CLOSE, 1);

   // Überprüfen, ob eine Position geöffnet ist
   if (PositionSelect(Symbol()))
     positionOpen = true;
   else
     positionOpen = false;

   // Long-Position eröffnen
   if (fastMAValue > slowMAValue && fastMAValuePrev <= slowMAValuePrev && !positionOpen)
     {
      OrderSend(Symbol(), OP_BUY, lotSize, Ask, 2, 0, 0, "MA Cross Long", 0, 0, clrGreen);
     }

   // Short-Position eröffnen
   if (fastMAValue < slowMAValue && fastMAValuePrev >= slowMAValuePrev && !positionOpen)
     {
      OrderSend(Symbol(), OP_SELL, lotSize, Bid, 2, 0, 0, "MA Cross Short", 0, 0, clrRed);
     }
  }
//+-------------------------------------------------

Respondido

1
Desenvolvedor 1
Classificação
(1095)
Projetos
1451
45%
Arbitragem
49
73% / 12%
Expirado
36
2%
Livre
2
Desenvolvedor 2
Classificação
(3)
Projetos
6
33%
Arbitragem
0
Expirado
0
Trabalhando
3
Desenvolvedor 3
Classificação
(107)
Projetos
166
33%
Arbitragem
12
25% / 33%
Expirado
0
Trabalhando
4
Desenvolvedor 4
Classificação
(354)
Projetos
558
33%
Arbitragem
24
67% / 8%
Expirado
16
3%
Livre

Informações sobre o projeto

Orçamento
30 - 35 USD
IVA (19%): 5.7 - 6.65 USD
Total: 36 - 41.65 USD
Desenvolvedor
27 - 31.5 USD
Prazo
para 5 dias

Cliente

(1)
Pedidos postados2
Número de arbitragens0