ENTRY BUY: when the fast MA crosses the slow from the bottom, both MA are going up ENTRY SELL: when the fast MA crosses the slow from the top, both MA 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.1; //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=50; //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=25; //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