runwiseFX

groundbreaking functionality for MetaTrader & TradingView

CASE STUDY: Indicator Signalling Partial Close

Here we'll look at how to configure the system for an indicator provides a partial close signal as well as a full close signal. The full close signal can be handled by the system out of the box, but partial close requires additional configuration, which we'll cover here.

The indicator for our case study, '1-2-3 Strike AO', has two color index buffers to signal partial exit, with buffer 1 for long partial exit and buffer 4 for short. The indicator outputs a non-null value when exit should happen. The EMPTY_VALUE mentioned is a special value MetaTrader uses when buffer is not signalling, also 0 is quite common as well. Indicator specifications supplied by the developer are as follows:

Begin by capturing the color index buffers for the partial exit, with separate entries in CONFIG | Indicator Values to Capture for long/buy and short/sell, as follows. Note, the use DefaultValue capture mode to capture raw value and Weighting set to blank so doesn't interferer with regular entry/exit.


We then just need to add an exit rule for partial exit to the end of the configuration txt file, which by default is called runwiseFX_CSA_Supplied_Rules.txt and is located in the MQL4\files folder of your MetaTrader data folder (or MQL5\files on MT5). You can use an ordinary text editor, e.g. Notepad. Here is the exit rule we need:



Here we've referenced the captured raw indicator values using an expression {t.buySell} that returns buy if buy/long trade and sell if sell/short trade, i.e. will access 123saoPEbuy or 123saoPEsell indicator reference IDs, as appropriate. Note, i. means access indicator reference ID. We've then checked if not 0 and not EMPTY_VALUE (which is provided by the expression k.emptyValue), as per indicator specifications (shame it's asking us to check for both). Finally, we've issued the command FORCE_CLOSE to do a partial close by 50%, which can be changed by altering the 50 value.