//+------------------------------------------------------------------+ //| TestCandles.mq5 | //| Copyright © 2020 MhFx7, All Rights Reserved | //| https://www.mql5.com/en/users/mhfx7 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2020 MhFx7, All Rights Reserved" #property link "https://www.mql5.com/en/users/mhfx7" #property version "1.00" //--- #include CTrade trade; //--- static ulong MagicNumber=123; //--- input double MinRange=25;//Minumum Range //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- if(IsNewBar() && !IsPosition()) { //--- double open=iOpen(_Symbol,PERIOD_M1,1); //--- double close=iClose(_Symbol,PERIOD_M1,1); //--- if(close>open) { //--- double range=MathRound((close-open)/_Point); //--- if(range>=MinRange) { //--- double ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK); //--- trade.SetExpertMagicNumber(MagicNumber); //--- trade.Buy(1,_Symbol,ask,ask-range*_Point,ask+range*_Point); } } //--- if(close=MinRange) { //--- double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID); //--- trade.SetExpertMagicNumber(MagicNumber); //--- trade.Sell(1,_Symbol,bid,bid+range*_Point,bid-range*_Point); } } } //--- } //+------------------------------------------------------------------+ //| IsPosition | //+------------------------------------------------------------------+ bool IsPosition() { //--- bool result=false; //--- int position_total=PositionsTotal(); //--- for(int i=0; i