Can Someone check ?

 

Hi there, 


cant get this code to happen. some an idea ? 


//+------------------------------------------------------------------+

//|                                                Scalping.mq5     |

//|                  Copyright 2023, MetaQuotes Software Corp.      |

//|                                              https://www.mql5.com|

//+------------------------------------------------------------------+

#property copyright "2023, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict


double LotSize = 0.01;

double Risk = 0.015;

double MaxDrawdown = 0.06;


int OnInit()

{

    double balance = AccountInfoDouble(ACCOUNT_BALANCE);

    LotSize = NormalizeDouble(balance * Risk / SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE) / 100000, 2);

    MaxDrawdown = balance * MaxDrawdown;

    return INIT_SUCCEEDED;

}


void OnTick()

{

    double ma = iMA(NULL, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE, 0);

    double bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);

    double ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);

    double stopLoss = NormalizeDouble(bid - MaxDrawdown / LotSize, SymbolInfoInteger(Symbol(), SYMBOL_DIGITS));

    if (ask > ma)

        OrderSend(Symbol(), OP_BUY, LotSize, ask, 3, stopLoss, 0, "", 0, 0, Green);

    else if (bid < ma)

        OrderSend(Symbol(), OP_SELL, LotSize, bid, 3, stopLoss, 0, "", 0, 0, Red);

}


 
  1. Wie können hier deutsch reden :)
  2. Code bitte als Code posten, also mit </> aus der Kopfzeile des Posts oder Alt+S.
  3. Bitte editiere Deinen Code entsprechend.
  4. "cant get this code to happen" ist so nichts sagend wie funktioniert nicht - was soll passieren, aber passiert nicht?
  5. Für solche Situationen gibt es im Editor den Debugger, man kann ganz leicht herausfinden, wann welche Variablen welchen Wert haben, sodass nicht das passiert was eigentlich gewollt.
  6. Außerdem lies mal nach (Cursor auf iMA & F1 drücken) wie man den Mittelwert abruft. So wie Du es machst wird der EA irgendwann abschmieren.
  7. Außerdem sollte man IMMER das Funktionsergebnis überprüfen - auch das kann man im Beispiel sehen!