Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

AveragePrice - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

AveragePrice - indicator for MetaTrader 5

AveragePrice - indicator for MetaTrader 5

AveragePrice - indicator for MetaTrader 5

MQL5 indicator for calculating the average price of hedging accounts

AveragePrice - indicator for MetaTrader 5

This code was generated by chatgpt, but I made some adjustments and posted the video to youtube:

In trading, often using a hedging account, you can hold both long and short positions on the same asset. A common problem for traders operating in this model is determining the average price for openings.

This article introduces an MQL5 indicator that automatically calculates the average price symbol and magic number for a given open position and displays the result on the chart.

This indicator takes the following steps:

The CalculateHedgeAveragePrice() function loops through all open positions and:

In the OnInit() function, we create a buffer which will store the average price displayed on the chart.

The OnCalculate() function updates the indicator buffer using ArrayFill(), making the code more efficient.

This MQL5 indicator is very useful for traders with hedging accounts , helping to monitor the average price of open positions. It can be customized for different assets and strategies.


Attachment download

📎 averageprice.mq5 (9.85 KB)

Source: MQL5 #57320

Verification code Refresh