I'm new to EA and I've been using free EA builders online.However I cannot find how to program the way I want, so I appreciate if I can get any advice.
What I want to capture is a sudden price movement due to news or any events.Like if more than 2% price change from previous close price, then buy etc.
For Example:Let's say USDJPY closed at 100.00at next bar, USDJPY closed at 97.88 (more than 2% drop)then BUY
Is this kind of EA possible?
The last closed bar's price is Close.
The bar previous to that is Close.
You probably only want to check at the start of a new bar, otherwise it will fire off orders all through the bar.
double threshold = 2.0;
static datetime last_bar = 0;
if(last_bar != Time)
last_bar = Time;
if(change <= -threshold)
/* code for OrderSend() buy */
else if(change >= threshold)
/* code for OrderSend() sell */