Tindtily

Dynamic Stop Loss Demo

Tindtily Atualizado   
What does this script do ?
This script is for pine script programmers and explains how to implement a dynamic stop-loss strategy. It is different from trailing stop-loss. Trailing stop-loss can only set the retracement value, but this script can take profit on part of the position at a fixed price and allows users to decide whether to take profit on all positions based on whether a certain track is breached or other conditions author want. In this demo, it use rsi crossover and crossunder to decide the strategy condition, and use close price as open price, and use lowest low / highest high as stop price, and use 1.5 risk ratio to calculate the fixed first profit price. It will take 50% position size when the first profit price was reached. Then it will close all rest positions when the inverse condition come out or the dynamic stop(calculated by ATR) breached or when the price back to the open price or the stop price.
How is this script implemented
When start strategy by strategy.entry, it gives a custom id which contains direction, openPrice, stopPrice, profitPrice, qty, etc. It can be get from the global variable strategy.posiition_entry_name.

Notas de Lançamento:
  • Compact code
  • Fix qty bug
Notas de Lançamento:
fix close condition bug
Notas de Lançamento:
update comment
Notas de Lançamento:
Optimization of dynamic-stop calculation method;
Simplify the getQty calculation method;
Add qty_precision settings;
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?