Discussing the article: "Market Simulation: Position View (VII)"

 

Check out the new article: Market Simulation: Position View (VII).

In this article, we'll start making some improvements to the position indicator so that we can interact with it and modify price lines or close a position directly through the position indicator. Before we move on to the implementation, there are a few things worth clarifying, especially for those who aren't familiar with this. The indicator cannot be used in any way to change anything on the trading server. This is because MetaTrader 5 has a security system in place that allows only Expert Advisors to modify orders and positions. No application other than an Expert Advisor can manipulate orders or positions.

In the previous article, Market Simulation: Position View (VI), we demonstrated how to make the Expert Advisor tell the position indicator whether it needs to be updated or not, or, in most cases, whether the position indicator should remain on the chart or be removed. Although what we covered in the previous article is quite interesting in terms of how to start designing certain components in MetaTrader 5, it is still not particularly practical. This is because we cannot work directly with the position indicator to specify that a price line, whether it is a Stop Loss or Take Profit line, should be moved or, at the very least, removed for that position.

Nevertheless, we still have one more issue, and it may be even more interesting to address it right now: the possibility of closing a position through some kind of interaction with the position indicator. This will eliminate the need to keep the terminal window on the Trade tab at all times, which can be useful during testing but becomes unnecessary if we can interact with the position indicator.

In this article, we'll start making some improvements to the position indicator so that we can interact with it and modify price lines or close a position directly by interacting with the position indicator. Before we move on to the implementation, there is one thing worth clarifying, especially for those who are not aware of it. Under no circumstances is it possible to use the indicator to change anything on the trading server. This is because MetaTrader 5 uses a security system that allows trades to be executed or positions to be opened only through Expert Advisors.


Author: Daniel Jose