//+------------------------------------------------------------------+ //| m14tdi2.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict input double lot=0.50; input int strattime=5; double hig0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",0,0); double hig1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",0,1); double hig2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",0,2); double hig3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",0,3); double med0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",1,0); double med1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",1,1); double med2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",1,2); double med3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",1,3); double low0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",2,0); double low1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",2,1); double low2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",2,2); double low3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",2,3); double rsi0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",3,0); double rsi1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",3,1); double rsi2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",3,2); double rsi3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",3,3); double sla0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",4,0); double sla1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",4,1); double sla2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",4,2); double sla3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",4,3); double slb0= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",5,0); double slb1= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",5,1); double slb2= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",5,2); double slb3= iCustom (NULL,PERIOD_CURRENT,"Traders Dynamic Index",5,3); double RSIII0= iRSI (NULL,PERIOD_CURRENT,10,PRICE_MEDIAN,0); double RSIII1= iRSI (NULL,PERIOD_CURRENT,10,PRICE_MEDIAN,1); double RSIII2= iRSI (NULL,PERIOD_CURRENT,10,PRICE_MEDIAN,2); //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(TDISL()=="CloseBuy") close(2222); if(TDISL()=="CloseSell") close(1111); if(Volume[0]<=1 && Orders()==0 && Hourfilter()==TRUE) { if(movStatus()=="buy" && rsi0 < 79) int tiketbuy =OrderSend(Symbol(),OP_BUY,lot,Ask,5,0,Ask+(50*Point),"sadasdasd",1111,0,clrBlue); if(movStatus()=="sell" && rsi0 > 30) int tiketsell=OrderSend(Symbol(),OP_SELL,lot,Bid,5,0,Bid-(100*Point),"asdsdassa",2222,0,clrRed); } } //===================== وضعیت اندیکاتور string movStatus() { if (slb3>med3 && slb1med1 && slb0>med0) {return ("buy");} else {return ("NOSignal");} } //===================== تابع چک مکدی برای بستن پوزیشن ها string TDISL() { if (slb1med1) return("CloseSell"); else return("NO SIGNAL"); } //------------------------------شمارش پوزیشنها------------------------------------ int Orders() { int num=0; for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderMagicNumber()==1111 || OrderMagicNumber()==2222) num++; } } return(num); } //----------------------------بستن پوزیشنها-------------------------------------- void close(int Magic) { for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderMagicNumber()==Magic) bool yccb =OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,clrGreen); } } } //----------------------------------فیلتر ساعت-------------------------------- bool Hourfilter() { if(Hour()>=strattime && Hour()<=23) return(true); else return(false); }