Experts: Simple EMA Cross EA with SL/TP and Magic Number

 

Simple EMA Cross EA with SL/TP and Magic Number:

A simple Expert Advisor based on the crossover of two EMAs (fast and slow), with configurable Stop Loss, Take Profit, lot size, and Magic Number.

Simple EMA Cross EA with SL/TP and Magic Number

Author: Edgar Alexis Benitez

 
// AJOUTE CA EN HAUT AVEC LES INPUTS
entrée double PerteMaxJour = 6,0 ; // Si -6$ la coupe pour la journée
input int MaxTradesJour = 6; // Max 6 trades

double PerteDuJour = 0;
int TradesAujourdhui = 0;
datetime DernierJour = 0;

void OnTick()
  {
   // RÉINITIALISER UN CHAQUE NOUVEAU JOUR
   if(DernierJour != TimeDay(TimeCurrent()))
     {
      PerteDuJour = 0;
      TradesAujourdhui = 0;
      DernierJour = TimeDay(TimeCurrent());
     }
   
   // DISJONCTEUR
   if(PerteDuJour <= -PerteMaxJour || TradesAujourdhui >= MaxTradesJour) return;
   si (PositionsTotal() > 0) retourner ;
   
   // ... le reste du code d'achat/vente ...
   
   // APRES UN TRADE FERME, TU CALCULES LA PERTE
   // Il faut ajouter la gestion de l'historique pour ça
  }