11410 lượt xem
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.
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.
Phát hành các Ghi chú:
somehow the alertcondition didn't make it into initial release. Thus added now.
Phát hành các Ghi chú:
Adjust the Options to your liking. One thing to note that using close for Trigger means that Signal can trigger though it closes above Stopline, while low can only cross once ;).
Hope it helps someone, more coming soon again.
Donations:
BTC
1JtEuaeWyEg7yYcFmh4XLe6Gj5viWqccZh
- Change wording for better understanding
- Update to newest Pinescript version 4
- Add Option for shifting the whole thing to the right
Adjust the Options to your liking. One thing to note that using close for Trigger means that Signal can trigger though it closes above Stopline, while low can only cross once ;).
Hope it helps someone, more coming soon again.
Donations:
BTC
1JtEuaeWyEg7yYcFmh4XLe6Gj5viWqccZh
Bình luận
Sorry for my bad explanation, I hope it's understandable
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())
Great work, very much appreciated!