You're right, there are two issues with the EA:
Let me fix both issues:
VolumeProfileFibEA.mq5
Fixed the Entry Price Issue:
ORDER_TYPE_BUY_LIMIT and ORDER_TYPE_SELL_LIMIT instead of market ordersFixed SELL Order Issues:
Added Order Expiration:
Added Detailed Logging:
These changes should ensure that:
The EA now uses pending limit orders instead of market orders, which is more appropriate for this strategy since you want to enter at a specific price level. The orders will be filled only when the price reaches the calculated equidistant point.
You were given the following instructions about the placement of the Fibonacci retracement:
"3. At 00h00 SAST: if the current price is above yesterday's Point of Control of the Fixed Range Volume Profile, add a Fibonacci retracement with the 100% level at yesterday's Lowest price and the 0% level at yesterday's highest price.
Place a BUY order at an equidistance between the Point of Control and 61.8% Fibonacci level. The order must satisfy the following: i. The stop loss for the order must be 35 pips ii. The stop loss must constitute 10% of the account balance iii. The position size must be calculated to satisfy condition (ii) above iv. The EA can only execute one open order at a time
At 00h00 SAST: if the current price is below yesterday's Point of Control of the Fixed Range Volume Profile, add a Fibonacci retracement with the 0% level at yesterday's Lowest price and the 100% level at yesterday's highest price.
Place a SELL order at an equidistance between the Point of Control and 61.8% Fibonacci level. The order must satisfy the following: i. The stop loss for the order must be 35 pips ii. The stop loss must constitute 10% of the account balance iii. The position size must be calculated to satisfy condition (ii) above iv. The EA can only execute one open order at a time."
However, it appears the placement of the Fibonacci is reversed in the EA. This affects the calculation of the equidistance between the POC and the 61.8 fib level. Fix it
The Fibonacci placement in the EA doesn't match the instructions. Let me fix both the Fibonacci placement and the corresponding 61.8% level calculation:
VolumeProfileFibEA.mq5
Fixed the Fibonacci Placement:
When price is above POC:
When price is below POC:
Added Detailed Logging:
Clarified Comments:
The EA now correctly places the Fibonacci retracement according to the instructions:
And it correctly calculates the 61.8% Fibonacci level based on this placement, which affects the entry price calculation (equidistance between POC and 61.8% Fib level).
The additional logging will help you verify that the Fibonacci placement and calculations are working as expected.