Can I capture the % price movement in EA?
Hi,
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.00
at next bar, USDJPY closed at 97.88 (more than 2% drop)
then BUY
Is this kind of EA possible?
Thanks.
The last closed bar's price is Close[1].
The bar previous to that is Close[2].
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[0]) { last_bar = Time[0]; double change=((Close[1]-Close[2])/Close[2])*100; if(change <= -threshold) { /* code for OrderSend() buy */ } else if(change >= threshold) { /* code for OrderSend() sell */ } }
Mochi888: I've been using free EA builders online.
I want, ... Is this kind of EA possible? |
|
Hi,
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.00
at next bar, USDJPY closed at 97.88 (more than 2% drop)
then BUY
Is this kind of EA possible?
Thanks.