//+------------------------------------------------------------------+ //| OnTimer.mq5 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //--- input int shift=0; //--- ulong MagicNumber=12; //--- int TakeProfitDist=25, StopLossDist=25; //--- static bool was_position=false; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create timer EventSetTimer(1); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy timer EventKillTimer(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- MqlTick tick_array[]; //--- ulong start_time=iTime(_Symbol,PERIOD_M1,0); //--- int copied_ticks=CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL,start_time); //--- static int last_size=0; //--- for(int i=last_size; iopen) { return(true); } else { return(false); } //--- } //+------------------------------------------------------------------+ //| isbearish | //+------------------------------------------------------------------+ bool isbearish(int shift) { //--- double close=(iClose(_Symbol,PERIOD_CURRENT,shift)); //--- double open=(iOpen(_Symbol,PERIOD_CURRENT,shift)); //--- if(close0) { //--- OrdersDeleteAll(); //--- was_position=false; } } } //--- } //+------------------------------------------------------------------+ //| OrdersDeleteAll | //+------------------------------------------------------------------+ void OrdersDeleteAll() { //--- for(int i=0 ; i