//— input parameters inputint tiks_before=500; // number of ticks till termination inputint pips_to_go=15; // distance in pips inputint seconds_st=50; // number of seconds given to the Expert Advisor //— globals datetime launch_time; int tick_counter=0; //+——————————————————————+ //| Expert deinitialization function | //+——————————————————————+ voidOnDeinit(constint reason) { //— Print(__FUNCTION__,” reason code = “,reason); Comment(“”); } //+——————————————————————+ //| Expert tick function | //+——————————————————————+ voidOnTick() { staticdouble first_bid=0.0; MqlTick tick; double distance; //— SymbolInfoTick(_Symbol,tick); tick_counter++; if(first_bid==0.0) { launch_time=tick.time; first_bid=tick.bid; Print(“first_bid =”,first_bid); return; } //— price distance in pips distance=(tick.bid-first_bid)/_Point; //— show a notification to track the EA operation string comm=“From the moment of start:\r\n\x25CF elapsed seconds: “+ IntegerToString(tick.time-launch_time)+” ;”+ “\r\n\x25CF ticks received: “+(string)tick_counter+” ;”+ “\r\n\x25CF price went in points: “+StringFormat(“%G”,distance); Comment(comm); //— section for checking condition to close the terminal if(tick_counter>=tiks_before) TerminalClose(0); // exit by tick counter if(distance>pips_to_go) TerminalClose(1); // go up by the number of pips equal to pips_to_go if(distance<-pips_to_go) TerminalClose(-1); // go down by the number of pips equal to pips_to_go if(tick.time-launch_time>seconds_st) TerminalClose(100); // termination by timeout //— }