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 Uzman Danışmanlar

İş tamamlandı

Tamamlanma süresi: 6 gün

İş Gereklilikleri

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

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(1268)
Projeler
1688
49%
Arabuluculuk
52
71% / 12%
Süresi dolmuş
37
2%
Serbest
2
Geliştirici 2
Derecelendirme
(32)
Projeler
49
73%
Arabuluculuk
4
50% / 0%
Süresi dolmuş
0
Serbest
3
Geliştirici 3
Derecelendirme
(151)
Projeler
232
32%
Arabuluculuk
18
39% / 33%
Süresi dolmuş
1
0%
Çalışıyor
4
Geliştirici 4
Derecelendirme
(436)
Projeler
688
34%
Arabuluculuk
33
70% / 9%
Süresi dolmuş
22
3%
Çalışıyor

Proje bilgisi

Bütçe
30 - 35 USD
Son teslim tarihi
to 5 gün