One of the good practices regarding the placement of trading orders is to set the stop loss and take profit. Sometimes it happens that we are at a very few pips to reach the take profit and close the order. Furthermore, this situation (failed the take profit) could encourage the trading without take profit and stop loss. In this article, we will see a way to avoid this situation and increase our revenues in automated strategies.

When we automate a strategy it is important to define the strategy based on the indicators that we will use and is also a good practice to define previously our stop loss and take profit values.
It sometimes happens that our strategy is only a very few pips to reach the defined take profit.
This very simple code can be added to a strategy putting it on bar closing that our strategy is working. In this case we consider an hourly bar.

This jforex code has the following steps:
First we define the value of our deltaPips (delta to reach the take profit). This piece of code run in all hourly bar closures, search for all orders that are in the FILLED state and verifies if the bar was closed less than x pips (value set in deltaPips) to reach the take profit. If that is the case the order is closed and we can achieve our goals.
In conclusion we should try to always put in our orders a stop loss and a take profit and this simple code can help us reach more times the desired take profit.
Translate to English Show original