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

 

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

We need a way to handle the graphical objects we create. The approach presented in the previous article works very well for certain scenarios. In this case, we will need something more complex, given the specific nature of the problem at hand. Therefore, we will not attempt to replace the ZOrder management mechanisms already present in MetaTrader 5, nor, of course, will we check which object is in the foreground or covered by another object. We are going to do something completely different. Here, I will show you what changes need to be made to the code in order to use part of what MetaTrader 5 already does for us.

In the previous article Market Simulation: Position View (IX), we began exploring how the Take Profit and Stop Loss lines should be moved. Since I want to explain to everyone—and make it as clear as possible—how and why changes are made to the code, in this article we will try to solve the problem presented in the previous article. The problem lies with ZOrder. If you're not sure what the ZOrder property means for objects, don't worry—just check out the previous articles in this series, where I explain why it's important to set this property correctly.

In addition, the question arises: how can we use ZOrder to our advantage? The answer is simple: we cannot. This seems absurd and completely pointless. Nevertheless, no matter how skilled a programmer you may be, dear reader, you will not be able to surpass what is already programmed in MetaTrader 5 for managing ZOrder.



To help you understand what we are going to do, we first need to look at a fairly simple piece of code that is, nonetheless, extremely useful for understanding how to approach our problem.


Author: Daniel Jose