RicardoSantos

[RS]Function Martingale Multiplier V0

EXPERIMENTAL:
WARNING:Martingale is susceptible to huge drawdown spikes, use at your own risk.

simple functions for martingale wins and losses, multiplier can be adjusted manually to increase/decrease performance/drawdown.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//@version=2
strategy(title='[RS]Function Martingale Multiplier V0', overlay=false, default_qty_type=strategy.cash, default_qty_value=1000, initial_capital=100000, currency=currency.USD)
wins_multiplier = input(defval=1.00, title='Scaling Multiplier for Consecutive Wins:')
losses_multiplier = input(defval=2.00, title='Scaling Multiplier for Consecutive Losses:')

// Setup trading conditions based on last performed trades performance.
direction = na(direction[1]) ? 1 : change(strategy.losstrades) > 0 and direction[1] > 0 ? -1 : change(strategy.losstrades) > 0 and direction[1] < 0 ? 1 : direction[1]

buy_cond = direction > 0 and change(strategy.opentrades) < 1
sel_cond = direction < 0 and change(strategy.opentrades) < 1

f_martingale_wins_multiplier(_multiplier) => _return = na(_return[1]) ? 1 : change(strategy.losstrades) > 0 ? 1 : change(strategy.wintrades) > 0 ? _return[1] * _multiplier : _return[1]
f_martingale_loss_multiplier(_multiplier) => _return = na(_return[1]) ? 1 : change(strategy.wintrades) > 0 ? 1 : change(strategy.losstrades) > 0 ? _return[1] * _multiplier : _return[1]

mode = change(strategy.wintrades) > 0 ? 1 : change(strategy.losstrades) > 0 ? -1 : nz(mode[1], 1)
trade_multiplier = mode > 0 ? f_martingale_wins_multiplier(wins_multiplier) : f_martingale_loss_multiplier(losses_multiplier)

trade_size = input(defval=100, title='Base trade value:')
trade_size_multiplied = trade_size * trade_multiplier

strategy.entry('B', long=true, qty=trade_size_multiplied, when=buy_cond)
strategy.entry('S', long=false, qty=trade_size_multiplied, when=sel_cond)

take_profit = input(defval=100, title='TP in ticks(1/10 of a pip):')
stop_loss = input(defval=100, title='SL in ticks(1/10 of a pip):')
strategy.exit('B', from_entry='B', profit=take_profit, loss=stop_loss)
strategy.exit('S', from_entry='S', profit=take_profit, loss=stop_loss)

plot(series=strategy.equity, title='Equity', color=black, linewidth=2)
plot(series=lowest(strategy.equity, 100), title='Base', color=red)