# User Guide – Metatrader Stop Loss/Take Profit Advisor

The following guide is for the Metatrader Stop Loss/Take Profit Advisor.

## Quick Start

Place the indicator onto the required chart. To view all of the output make sure the Metatrader setting “**shift end of the chart from right border**” is switched on. See the image below.

By default the trade time is set at 1 day and the target win ratio is 75%. The stop loss and take profits are calculated for the buy side. Adjust the settings as needed.

## Outputs

The indicator generates the following data outputs.

Signal/Mode | Name | Description |
---|---|---|

0 | SL | Buy/sell stop loss |

1 | TP | Buy/sell take profit |

Open Metatrader’s data window (CTRL+D) to show the signal values. You can hover with the mouse cursor over any point to display the value in the data window.

## Input Settings

Input setting | Comment |
---|---|

Target trade time (in days ) | Stops and profits will be calculated according to the trade time |

Target win ratio | The ratio of winners to losers you are trying to achieve |

Market behavior | Specify market expectations such as trend reversal. Leave “random” if none. (0=None, 1=Trend, -1=Reverse Trend) |

Trade side (main signal to output) | Which sl/tp lines should be displayed – buy side/sell side (0=Buy, 1=Sell) |

Curve 1 % | The percentage for the 1st maximal curve |

Curve 2 % | The percentage for the 2nd maximal curve |

Curve 3 % | The percentage for the 3rd maximal curve |

Curve 4 % | The percentage for the 4th maximal curve |

Curve 1 color | Color setting |

Curve 2 color | Color setting |

Curve 3 color | Color setting |

Curve 4 color | Color setting |

SL color | Color setting |

TP color | Color setting |

Text color | Color setting |

Show detailed output | Show textual output on chart (0=No, 1=Yes) |

A further explanation of the inputs is provided here.

**Frequently Asked Questions**

The following are the most frequently asked questions.

## What are the curves on the chart and how do I use them?

The curves show the probability of the price reaching (touching) a certain level within a certain time. The curves extend forwards in time, from the current time. For example, with the red 20% curve, the price has a 20% chance of touching the curve. In other words, 80% of the time, the price will remain inside that curve. The curves get bigger as time increases because the chances of the price moving further away also increase.

## What do “Target Trade Time”, “Win Ratio” and “Averaging Period” mean and what is their relationship to one another?

** Win ratio:** The “win ratio” is a target percentage and is the ratio of winning to losing trades that you are aiming for. For example if “win ratio” is 0.75 that means you want to win 3 out of every 4 trades (75%).

** Target trade time:** The “Target Trade Time” is set in days and is the duration for your trades. For example:

- M5 chart
- Target Trade Time=1.00 days (24 hours or 288 chart bars)
- Target Win Ratio=0.75 (75%)

With this setup the indicator will output stop loss/take profit levels such that a trade is likely to reach either the stop loss or take profit within 24 hours. The size of the stop and profit level are computed such that the ratio of winners to losers will be 75% given a) the current market volatility and b) any trending condition.

Note that the maximal curves never reach zero. This is because there is always a chance (*non-zero* probability) that the trade will not close within the time period. For that reason it’s impossible to set an exact win ratio but only place it within a target range.

## What is the numerical output in the data window and how can it be used?

The stop and profit levels are output in the data window and in the panel (if displayed). The values are output as price levels (not pips or points).

- SL – the stop loss price level.
- TP – the take profit price level.

## The indicators seems to return equal values for the sell and the buy side, i.e. sell TP = buy TP and sell SL = buy SL. Is this correct?

This will depend on the inputs and the market. With the random (flat) market setting the size of the stop level can be the same on both sides. This is because there is no prior assumption of a trend. The other two options for trending and reverse would usually give a different value for the buy and sell side unless there is no trend.

## What is vol?

The volatility is displayed in the panel. It is shown for information purposes only. The formula used is:

**Vol=ATR( averaging period ) / Point size. **

Volatility is adjusted for trend when a trend setting is used.

## Why would a trader look to a signal for a better chance of losing than winning – that is why would anyone set a win ratio less than 50 percent?

There is a fixed relationship between the profit size, stop size and the win/lose ratio. With a win ratio less than 50% you also have a profit value that is bigger than the loss value so it can still result in a profitable strategy.

You can still create a positive return provided you predict the correct movement of the market over the period of the trade.

## Can I use this indicator to decide which side to trade?

The purpose of this indicator is to advise on stop loss and take profit placement. It doesn’t recommend which way to trade. By that it doesn’t tell you to buy or to sell. The stop loss and take profit values that are displayed are based on the volatility of the market and, if you choose the trending condition (see market type). These are optimized to reach a certain win ratio. So suppose you are aiming for a 60% win ratio for a 3 day-trade the indicator will tell you where to place the stop and profit for optimum effect.

## If I set the target win ratio higher than 0.50 the SL is always greater than the TP. Why can’t I set my stop losses smaller?

Because the numbers won’t work. With a flat market, if you set the target win ratio above 0.50 (50 percent) the SL will be bigger than the TP. If you set the target win ratio less than 0.50 the SL will get smaller and the TP bigger.

With the other market types there would be a bias depending on the trend. The two most important settings are the target trade time and win ratio. If you adjust the win ratio there will be changes in the position of the stop and profits.

For example with EURUSD setting the win ratio to 0.35 currently gives an SL=48 pips and TP=72 pips. The win ratio is 24% and lose ratio is 52%. So this means there is 24% chance that after 1 day this trade will close in profit and 52% chance it will close in the red. There is a 24% chance it doesn’t close at all. The “flat” market type is unbiased because there is no assumption about trend – only on volatility which could swing the market either way.

## Does the SLTP Advisor use the same calculations found in the stop loss calculations Excel spreadsheet?

### I don’t see how to get the output for Trade Wins/Loses/Open or estimated Win Ratio from the SLTP Advisor?

The Excel spreadsheet is only a basic demo. There are no live data feeds into the spreadsheet and due to limitations in Excel the spreadsheet only uses a simplified model.

**Probability Trade Wins / Loses / Open or Estimated Win Ratio from the SLTP Advisor:**

This is displayed in the panel as *p*(win), *p*(lose) and *p*(open). To display this you will need to switch on the “show panel” option. This output isn’t displayed in the indicator graph because it’s usually the stop loss and take profit which is used in practice. The SL and TP are shown on the signal lines for the buy and sell side. If you look at Metatrader’s Data Window it should show the labels for all outputs.

## What does the SLTP Advisor “Target Win Ratio” do?

The target win ratio is the ratio of winning trades to losing trades that the trader wants to achieve. The algorithm uses this number to estimate take profit and stop loss points that will achieve this win ratio. It is a hypothetical number because as explained above it is impossible to guarantee that it will be achieved. Generally a high win ratio will give a wider SL and narrower TP whereas a low win ratio will give narrower stop loss and wider take profit.

## Why do the indicator’s values sometimes jump in steps rather than smoothly?

To calculate the probabilities for the maximal curves there is a conversion from a continuous discrete curve. This means you can see step changes in the values of the probabilities as it moves from one nterval to the next. That means if volatility is very small or values are at extreme points you can see big incremental changes in *p*(win) and *p*(lose).

The “Target Win Ratio” is as it says a target. Since the calculation is made on discrete intervals there may be no solution to a given win ratio so in this case it jumps to the next point.

## When I extend the time period why do the probabilities nearly always stay the same?

If you extend the days (time) out it just extends the curve out. The “flat” market type creates symmetric curves. So when the “pip” value increases on both sides (stop and profit) the win ratio stays the same. The ratios are then in nearly equal measures so the probabilities stay the same or close to.

Using a longer target time will make the indicator sample a wider time period in the chart. The averaging period should be extended as you extend out the trade time.

## Why does the output panel sometimes appear empty or in the wrong place on the chart?

The indicator hasn’t updated because the chart needs to be refreshed. This refreshing usually happens automatically in Metatrader. If it doesn’t just open the indicator’s settings box (Ctrl+I) and click OK.

## If the “Target Trade Time” is the same (in minutes) and the win ratio is the same but on a different time frame why are the SL and TP values that the indicator shows different?

The indicator may give slightly different stop/profit levels on different time frames but where the trade time and win ratio is the same. This is because there will be different intra-bar volatility when you go down to a lower time frame (see image below). This detail isn’t used at longer time frames.

## How do I call the indicator from MQL?

Accessing the indicator outputs can be achieved easily with MQL using the custom indicator function (iCustom). The example code below demonstrates for MQL4:

double sl, tp; sl=iCustom(NULL,PERIOD_CURRENT,"test\myindicator",... comma separated list of parameters ... ,0,1); tp=iCustom(NULL,PERIOD_CURRENT,"test\myindicator", ... comma separated list of parameters ... ,1,1);

Simply replace “test\myindicator” with the name of the indicator in your local Metatrader folder. Replace the parameters in the list with the required values. For MQL5 the call is:

```
int MA_handle=iCustom(NULL,PERIOD_CURRENT,"test\myindicator",... comma separated list of parameters ... );
```

## More

Video: https://youtu.be/R-XWDP3-ORs

Article: http://forexop.com/strategy/stop-loss-profit-placements-max-returns/