StdDev based EA triggers one candle too late
You are using PRICE_OPEN to get standard deviation value.
double Std_Cur = iStdDev(NULL,0,10,0,MODE_SMA,PRICE_OPEN,0); double Std_Old = iStdDev(NULL,0,10,0,MODE_SMA,PRICE_OPEN,1);
Check if the StdDev indicator on the image is set to use open price and then verify conditions.
StdDev values in the picture are as follows (starting within the red circle):
Small Black Candle: 0.0008
Large White Candle: 0.0018
Entry Candle: 0.0030
I think your problem is checking just on opening a new candle. I'm sure that the value of StdDev on Open[Large White Candle] isn't 0.0018 but less. You have to decide if you check values only on opening a new candle or continuously.
As @Drazen Penic said you are using PRICE_OPEN and it's a little bit strange.
Hello everyone,
I ran into a problem that I cannot really explain, so I hope someone is able to explain to me where my line of thought is wrong. I have written a draft version of an Expert Advisor, that is based on Standard Deviation (Entry-Trigger) and ADX (Direction-Trigger for Buy/Sell). However, my EA does work the way I want it to, but simply enters one candle too late. This can be seen here:
The basic idea is, that if the (Standard Deviation of the current period) > (Standard Deviation of last period * Multiplier), then the EA opens a position into the direction of what is higher of ADX (so if PLUSDI > MINUSDI in the current period, then it opens a BUY and vice versa). Now I don't see where I went wrong in my coding, but I assume I have a logical mistake because I only allow the EA to act once every time a new candle is opened. I first thought it is because it was because of the Multiplier setting, but I tested several settings and it didn't change anything.
StdDev values in the picture are as follows (starting within the red circle):
Small Black Candle: 0.0008
Large White Candle: 0.0018
Entry Candle: 0.0030
I obviously want it to already enter on the large white candle, but I cannot get it to do so. Maybe I missed something in my indicator settings or the "only when new candle" part screws it up? The code is as below:
Most likely it is an obvious mistake that I am simply not able to see. Hope someone can explain to me what I seem to be missing.
Thank you very much!
- Chris
(I noticed I might have posted this accidently in the wrong section. If so, can one of the mods please be so kind to move it to the right one? Sorry and thanks!)