//+------------------------------------------------------------------+ //| Experto Estrategia Sombra_v2-0.mq4 | //| HECTOR PEGUERO | //| "LO MAS DURO" | //+------------------------------------------------------------------+ #property copyright "HECTOR PEGUERO" #property link "LO MAS DURO" #property version "2.00" #property strict #property description "This Expert Advisor open orders at the crossover of two simple moving average (EMA) indicators" #property description " " #property description "DISCLAIMER: This code comes with no guarantee, you can use it at your own risk" #property description "We recommend to test it first on a Demo Account" /* ENTRY BUY: when the fast EMA crosses the slow from the bottom, both EMA are going up ENTRY SELL: when the fast EMA crosses the slow from the top, both EMA are going down EXIT: Can be fixed pips (Stop Loss and Take Profit) or the entry signal for the next trade Only 1 order at a time */ extern double LotSize=0.01; //Position size extern bool UseEntryToExit=true; //Use next entry to close the trade (if false uses take profit) extern double StopLoss=20; //Stop loss in pips extern double TakeProfit=20; //Take profit in pips extern int Slippage=2; //Slippage in pips extern bool TradeEnabled=true; //Enable trade extern int MAFastPeriod=10; //Fast moving average period extern int MASlowPeriod=20; //Slow moving average period //Functional variables double ePoint; //Point normalized bool CanOrder; //Check for risk management bool CanOpenBuy; //Flag if there are buy orders open bool CanOpenSell; //Flag if there are sell orders open int OrderOpRetry=10; //Number of attempts to perform a trade operation int SleepSecs=3; //Seconds to sleep if can't order int MinBars=60; //Minimum bars in the graph to enable trading //Functional variables to determine prices double MinSL; double MaxSL; double TP; double SL; double Spread; int Slip; //Variable initialization function void Initialize(){ RefreshRates(); ePoint=Point; Slip=Slippage; if (MathMod(Digits,2)==1){ ePoint*=10; Slip*=10; } TP=TakeProfit*ePoint; SL=StopLoss*ePoint; CanOrder=TradeEnabled; CanOpenBuy=true; CanOpenSell=true; } //Check if orders can be submitted void CheckCanOrder(){ if( BarsMAFastPrev && MAFastCurr>MASlowCurr){ CrossToBuy=true; } if(MASlowPrev