Hello Forum, good day.
I'm trying to finish a Pending Orders Expert Advisor that takes the OHLC prices from the previous candle/bar right when a new bar/candle is created and +DI > -DI for Buy Orders and +DI < -DI for Sell Orders, but somehow there are times that it takes this values from two or more candles behind. Also I need that for Buy Orders only when the previous candle is Black the order is placed/filled and for Sell Orders only when the previous candle is White, but I don't know what I'm missing that this is being ignored sometimes. I'm new to MQL5 and would really appreciate if someone could help me out with this or point me in the right direction.
Here is what I have so far:
Regards and thank you in advance,
codeMolecules
Please explain your problem more carefully. What is the exact meaning of text I highlighted. Provide screenshots or better logs.
There is no print statement in your code, check your trigger values by printing them to the logs. Also there is almost no error checking/processing.
Please explain your problem more carefully. What is the exact meaning of text I highlighted. Provide screenshots or better logs.
There is no print statement in your code, check your trigger values by printing them to the logs. Also there is almost no error checking/processing.
Hello angevoyageur, good day. Thanks for your response.
What I’m trying to do is a simple EA that places a BuyStop order when +DI > -DI and the previous candle is black; for SellStop orders +DI < -DI and the previous candle is white. The timeframe is daily (D1) and I need to check for this conditions right at the moment a new candle is being created (at 00:00 h.), but I think that I’m doing this when the candle creates completely, (on new bar, when the day ends: 23:59), not when it starts.
When this conditions must be checked and the order should be placed is right at 00:00 h.; I need the values to be taken from the previous candle, but there are orders that the values are taken from two or more candles behind the day it was placed.
I’ll attach the results from the journal in the Strategy Tester for the first 5 operations and the chart from the MetaTrader so it is better illustrated. I’m testing this EA with XAUUSD on the period of 2014. The next symbology is related to the first 5 orders that are placed and are circled/numbered from 1 - 5:
Red circles: Orders that should not exist
Green circles: Orders that should exist
Blue circles: ADX indicators
Red line: first order that should be placed (16.01.2014) with the values of the previous candle (15.01.2014). This is because here is the first time that +DI > -DI and the previous candle is black.
Black arrow: points to the previous candle from where the values should be taken for the first order (16.01.2014).
Chart explanation:
1. At this point, +DI > -DI but the previous candle is not black, therefore this order should’t exist. The values are taken from two candles behind, not the previous one.
2. As well as the first order, +DI > -DI but the previous candle is not black, so then this order should not exist. The values are taken from two candles behind, not the previous one.
3. This is the first order that is placed correctly, because at this point +DI > -DI and the previous candle is black. This is taking the values correctly, from the previous candle.
4. At this point, +DI > -DI but the previous candle is not black, so then this order should not exist.
5. This order should exist, because at this point +DI > -DI and the previous candle is black. But somehow it first takes the values from the candle 4 days behind (at 31.01.2014) and then it takes the values from this same day (05.02.2014).
Help will be much appreciated.
Regards and thank you in advance,
codeMolecules
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Forum, good day.
I'm trying to finish a Pending Orders Expert Advisor that takes the OHLC prices from the previous candle/bar right when a new bar/candle is created and +DI > -DI for Buy Orders and +DI < -DI for Sell Orders, but somehow there are times that it takes this values from two or more candles behind. Also I need that for Buy Orders only when the previous candle is Black the order is placed/filled and for Sell Orders only when the previous candle is White, but I don't know what I'm missing that this is being ignored sometimes. I'm new to MQL5 and would really appreciate if someone could help me out with this or point me in the right direction.
Here is what I have so far:
Regards and thank you in advance,
codeMolecules