//+------------------------------------------------------------------+ //| Day Trading.mq4 | //| Copyright © 2005, NazFunds Company | //| http://www.nazfunds.com | //+------------------------------------------------------------------+ extern double TakeProfit = 25; extern double Lots = 1; extern double TrailingStop = 0; extern double StopLoss = 50; //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double rsi1_1, rsi1_0; double stoc2d_1, stoc2d_0, stoc2k_1, stoc2k_0; double MacdCurrent, MacdPrevious, SignalCurrent; double sar1_1, sar1_0; double mom3_1, mom3_0; int cnt, ticket, total; // initial data checks if(Bars<10) { Print("bars less than 10"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); } // to simplify the coding and speed up access stoc2d_1=iStochastic(NULL,0,10,7,3,MODE_SMA,NULL,MODE_SIGNAL,1); stoc2d_0=iStochastic(NULL,0,10,7,3,MODE_SMA,NULL,MODE_SIGNAL,0); stoc2k_1=iStochastic(NULL,0,10,7,3,MODE_SMA,NULL,MODE_MAIN,1); stoc2k_0=iStochastic(NULL,0,10,7,3,MODE_SMA,NULL,MODE_MAIN,0); mom3_1=iMomentum(NULL,0,14,PRICE_OPEN,1); mom3_0=iMomentum(NULL,0,14,PRICE_OPEN,0); MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_TYPICAL,MODE_MAIN,0); MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_TYPICAL,MODE_MAIN,1); SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_TYPICAL,MODE_SIGNAL,0); sar1_1 =iSAR(NULL,0,0.02,0.2,1); sar1_0 =iSAR(NULL,0,0.02,0.2,0); // identifying open orders total=OrdersTotal(); if(total<1) { if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(sar1_0 <= Ask && sar1_1>sar1_0 && mom3_0<100 && MacdCurrent>SignalCurrent && stoc2k_0<=20) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,0,0,Green); if(ticket>0) Print("Day Trading Buying : ", Symbol()); { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } return(0); } // check for short position (SELL) possibility if(sar1_0 >= Ask && sar1_1100 && MacdCurrent=20) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,0,0,Red); if(ticket>0) Print("Day Trading Selling : ", Symbol()); { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } return(0); } return(0); } // control of open orders for(cnt=0;cnt= Ask && sar1_1100 && MacdCurrent=70) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); return(0); } // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()sar1_0 && mom3_0<100 && MacdCurrent>SignalCurrent && stoc2k_0<=35) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); return(0); } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } //+------------------------------------------------------------------+