//+------------------------------------------------------------------+ //| delta MA bar driver.mq4 | //| Leyoye trading corp. | //| | //+------------------------------------------------------------------+ //| Lionel HOUBA | //| | //+------------------------------------------------------------------+ #property copyright "Lionel HOUBA" #property link "" //----The goal of this EA is to catch a market returnment after a strong market reaction //----analysing the delta between the MA and the bar //----You can set the trading hours, Take profit, Stop loss, delta MA bar, volatility level. //---- input parameters extern double lotsize = 0.1; extern double MAXORDERS = 1; int ticket; extern double take_profit = 0.003; extern double stop_loss = 0.003; extern double hour_start = 0; extern double hour_end = 24; extern double moving_period = 14; int delta_MAbar ; extern double delta_MAbarchoice = 0.004; extern double ATR_value = 0.0004; double MA; return; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int open=OrdersTotal(); for(int qw=0;qw<open;qw++) { OrderSelect(qw,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol()) return(0); } //---- double MA; double delta_MAbar; //----defining MA : MA=iMA(NULL,0,moving_period,0,MODE_SMA,PRICE_OPEN,0); //----defining delta MA/bar = mobile average - last open delta_MAbar = MA-Open[0]; //---BUY conditions------------------------------------------------------- // if the delta betwwen the MA and the last is more than the defined GAP (enter this value previously) if ( (delta_MAbar>delta_MAbarchoice) //---- limitation of the number of open positions (not more than one open position simultaneously) &&(OrdersTotal() < MAXORDERS) //---- if volatility (ATR) is enough (enter this value - put 0.0001 to neutralise this function) && (iATR(NULL,0,12,0)>ATR_value) ) OrderSend (Symbol(),OP_BUY,lotsize,Ask,3,Open[0]-stop_loss,Open[0]+take_profit,"",0,0,Red); //----SELL conditions------------------------------------------------------------------------+ if ( (delta_MAbar<-delta_MAbarchoice) //---- limitation of the number of open positions &&(OrdersTotal() < MAXORDERS) //---- volatility (ATR) is enough && (iATR(NULL,0,12,0)>ATR_value) ) OrderSend(Symbol(),OP_SELL,lotsize,Bid,3,Open[0]+stop_loss,Open[0]-take_profit,"",0,0,Green); return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
thank you very much for your help roger!