//+------------------------------------------------------------------+ //| ai_tester_strategy.mq4 | //| Aleksandr M | //| https://tmsrv.pw | //+------------------------------------------------------------------+ #property copyright "Aleksandr M" #property link "https://tmsrv.pw" #property version "1.00" #property strict //Do not forget to add url( https://tmsrv.pw/send ) to Allowed: //Metatrader->Tols->Options->Expert Advisors int OnInit(){ if(!tms_send(StringFormat("EA demo_tmsrv is Active, symbol - %s",Symbol()))) { MessageBox("Something went wrong, check the log"); return(INIT_FAILED); } return(INIT_SUCCEEDED); } void OnTick(){ if(iRSI(NULL,0,11,PRICE_CLOSE,1)>30 && iRSI(NULL,0,11,PRICE_CLOSE,0)<30) { tms_send(StringFormat("%s RSI is oversold - time to BUY",Symbol())); } if(iRSI(NULL,0,11,PRICE_CLOSE,1)<70 && iRSI(NULL,0,11,PRICE_CLOSE,0)>70) { tms_send(StringFormat("%s RSI is overbought - time to SELL",Symbol())); } } datetime _tms_last_time_messaged; bool tms_send(string message, string token="{YOUR_TOKEN_HERE}"){ // You can set token here for simply usage tms_send("you message"); const string url = "https://tmsrv.pw/send/v1"; string response,headers; int result; char post[],res[]; if(IsTesting() || IsOptimization()) return true; if(_tms_last_time_messaged == Time[0]) return false; // do not send twice at the same candle; string spost = StringFormat("message=%s&token=%s&code=MQL",message,token); ArrayResize(post,StringToCharArray(spost,post,0,WHOLE_ARRAY,CP_UTF8)-1); result = WebRequest("POST",url,"",NULL,3000,post,ArraySize(post),res,headers); _tms_last_time_messaged = Time[0]; if(result==-1) { // WebRequest filed if(GetLastError() == 4060) { printf("tms_send() | Add the address %s in the list of allowed URLs on tab 'Expert Advisors'",url); } else { printf("tms_send() | webrequest filed - error № %i", GetLastError()); } return false; } else { response = CharArrayToString(res,0,WHOLE_ARRAY); if(StringFind(response,"\"ok\":true")==-1) { // check server response printf("tms_send() return an error - %s",response); return false; } } Sleep(1000); //to prevent sending more than 1 message per seccond return true; }