//+------------------------------------------------------------------+ //| Gervis.mq5 | //| Copyright 2021, Nkondog Anselme Venceslas | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, Nkondog Anselme Venceslas" #property link "https://www.mql5.com" #property version "1.00" #include #include CiMA* sma; CiMA* ssma; #include // Description of variables #include // Error library #include // Prechecks #include // #include #include // Scan for opened positions #include //Check transaction history #include //Manage trade dynamic open and close conditions #include // Check buy and sell entries signals and execute them #include // Lot size calculate #include // Close opened positions #include //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //sma = new CiMA(); //ssma = new CiMA(); //sma.Create(gSymbol, PERIOD_CURRENT, InpMAPeriods, InpMAAppliedPrice, InpMAMethod, PRICE_CLOSE); //ssma.Create(gSymbol, PERIOD_CURRENT, 200, InpMAAppliedPrice, InpMAMethod, PRICE_CLOSE); InitializeVariables(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- SymbolInfoTick(_Symbol,last_tick); TimeCurrent(dt); CheckOperationHours(); //isQualifiedCandle(0); OrderClose(); ScanPositions(); CheckSpread(); EvaluateEntry(); ExecuteEntry(); Comment( "Expert Advisor by Anselme Nkondog (c) 2021\n "+ " Hour " + dt.hour + " Min "+ dt.min+"\n" " Last Highest Price " + gLastHighestPrice + " Price %change "+ gPriceChange); } //+------------------------------------------------------------------+ //Initialize variables void InitializeVariables() { gIsNewCandle=false; gIsTradedThisBar=false; gIsOperatingHours=false; gIsSpreadOK=false; gLotSize=InpDefaultLotSize; gTickValue=0; gTotalOpenBuy=0; gTotalOpenSell=0; gSignalEntry=SIGNAL_ENTRY_NEUTRAL; gSignalExit=SIGNAL_EXIT_NEUTRAL; Print("Variables intialized"); } //Check and return if the spread is not too high void CheckSpread() { //Get the current spread in points, the (int) transforms the double coming from MarketInfo into an integer to avoid a warning when compiling long SpreadCurr=SymbolInfoInteger(gSymbol, SYMBOL_SPREAD); Print("Spread ", SpreadCurr); if(SpreadCurr<=InpMaxSpread) { gIsSpreadOK=true; } else { gIsSpreadOK=false; } } //+------------------------------------------------------------------+