TradingView
Damasta
2017년 11월 14일 오후 8시 23분

Simple Trailing stop 

설명

Since my exchange doesn't support trailing stop I made a script for it.

It is fully configurable, which means you can set the bars for calculation, the offset and sources for trigger and calculation.

The original purpose for me was to send a command to my bot. If you like it please comment and check out my other scripts.

릴리즈 노트

somehow the alertcondition didn't make it into initial release. Thus added now.
코멘트
migm
Hey Sir, can you explain what "Source Trailing Stop calculation" and "Source Trigger" are? i dont understand what these option do.
Damasta
@migm, Well the first is the source that is used to draw the Trailing-Stop line. The second is the source that triggers the signal when crossing the line, which is useful if you don't want it to trigger when you use signals on close of the bar only and use close for example. That way a short dip breaking the line wouldn't trigger the signal when close gets above again afterwards.

Sorry for my bad explanation, I hope it's understandable
LC01
this is very useful. Not only for the bot but for backtesting.
However, by adding this code to my simple script I get an error message "Add to Chart operation failed, reason: The script must have one study() or strategy() function call"
I'm new to pinescript, trying to learn step by step so I'd much appreciate some help :)
I believe there should be an exit() command in order to backtest with the trailing stop, right?
Here is my code, a simple EMA crossover.. I

short_ema = ema(close, 9)
long_ema = ema(close, 30)

plot(short_ema, color =red)
plot(short_ema, color =green)

entry() => crossover( short_ema, long_ema)
exit() => crossunder( short_ema, long_ema)

strategy.entry(id = "long_ma", long = true, when = entry())
strategy.close(id = "long_ma", when = exit())

cyatophilum
You can have both integrated Trailing Stop and Trailing Take profit, and create alerts from it.
tradingview.com/script/8B6QcKN2-Cyatophilum-Altcoins-Trader-ALERTSETUP/
Damasta
@cyatophilum, true, just copy this code and do it for the other side. Would be a great Beginner level scripting example
cryptohan
Any way to make this into a two-way stop? I.e. stops for closing longs.
cryptohan
Nevermind! It was as simple as changing (1-(offset/100) to (1+(offset/100).

Great work, very much appreciated!
CryptoFluxx
wow exactly what i was looking for. Works great with trading view. THANK YOU!
Dionyzus
not really a trailing stop maybe a moving average stop
Damasta
Oh my bad for having the early WIP-strat report in here, long time no publish :O
더보기