please help me

 

hi

I would like add something in the next EA, but I dont know how to do that

first of all I would like to add 2 thing in "input" the first one is a number of period and the second is a number of pip.

and I would like that the EA only take a position when the real number of pip is lower then the number of pips we set in input for the number of period we set

example: in "input" we set: number of period: 10

number of pips: 50

so the EA will only take a position if in the last 10 period, the real number of pips that the market moved is lower then 50 pips.

if in the last 10 period the currency moved higher then 50 pips, we dont want the EA to take a position

-

-

thank you very much

-

-

-

-

-

-

-

-

-

//----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);
}
//+------------------------------------------------------------------+