Gesundheit

Customizable trailing Stop For Manual Entries

3778 просмотров
167
3778 8
Here's how to create a trailing stop with a manual buy order, on an exchange that does not support native trailing stops. Code can easily be copy+pasted into your normal algos.

To set the entry price for your manual trade, specify the bar time when the trade was made. Note that the time you specify needs to correspond to an opening time on your chart--if it's a 3 hour chart, 6 pm or 9 pm will work, but 8 PM will not. It's not as bad as it sounds though, read on :)

Per usual I keep multiple options open.

Special features in this script:
  • Change time frame for trailing
  • Specify trailing parameter (high, close, hlc3, etc.)
  • Change time frame for stop loss trigger (use a shorter time frame for earlier exits!)
  • Specify trigger parameter (close, low, hlc3, etc.)

Remember that annoying issue where you might not be able to precisely specify entry price, because you want to use 3 hour closing prices for your trailing stop but you bought in at 7:41 pm? Add this indicator to a 1 minute chart and set your start time to 19:41, then set the trailing time frame to 3 hours!

Next stop is v2, where we take profits along the way before stop loss gets triggered.
Информация о релизе: Disabled plotting of variables outside of the trading period, so the script does not mess up chart scaling.

Attempted to add trailing stop capability for short trades, but for some reason it's not working. Anybody have a clue?
Информация о релизе: Trailing stop now works for shorts :)
Удалить из избранных скриптов Добавить в избранные скрипты
You can actually have both integrated Trailing Stop and Trailing Take profit, and create alerts from it.
Ответить
First of all, thanks for the hard work in developing this as well as the willingness to share with all of us!

I'm a little confused as how to use this and achieve the desired results however; let me explain my scenario:

I was trying to plot a trailing stop as part of a strategy I'm developing on the 4-hour chart. When I added all the information for the candle that I would have triggered in on, the script placed my entry line well below the candle on the chart. As such, I changed my time period to 1-hour intervals and assigned the trigger bar to one that would represent the value of my entry. This placed the entry level right where I wanted it. However, when I moved back to the 4-hour chart, the script broke and the entry line, as well as the trailing stop line disappeared. I had the box unchecked for use the current time frame for the indicator.

Any feedback would be incredible. Thanks!
Ответить
brianmontgomery brianmontgomery
Note: I'm trying to use this for a cryptocurrency chart so the chart has candles for every hour/4hour interval
Ответить
Hi,

I have tried using this for a daily chart but I can't get it to plot anything on chart.

Would you be able to let me know what inputs I need to use for a daily and weekly chart time frame.

TIA
+2 Ответить
Gesundheit Qtrader83
Hi @Qtrader83, the start time needs to be a time that is represented on the chart you are using. So if you purchased today 2/12/18 at 11:30 AM, to use on a daily chart you'd input 2/12/18 0:00.
Ответить
could this be modified to sell if price crossed Kijun Sen (or its value) for ichimoku cloud indicator? honestly i'm terrified of messing with code, but this looks interesting.
+1 Ответить
Gesundheit MSNEAD1992
@MSNEAD1992, nothing to be afraid of :) Do you mean using the Kijun Sen as a stop loss trigger? Ichimoku is a built-in indicator, so it's already possible to set up an alert for price crossing Kijun Sen.

This is what the Kijun Sen would be on the same chart pictured above. You'd end up selling on the 1st or 3rd depending on whether you wait for confirmation, which is fine. You could buy lower on the 3rd, but would again miss out on the final rise on the 7th.

In case you meant using Kijun Sen to take profit, I did make a version that sells on ema crosses so you can sell a little bit at a time until the final stop loss gets triggered.



That version will be much easier to modify. On line 66 just change the definition of tpma so it corresponds to the Kijun Sen instead of an EMA, and tplen on line 22 can define the period for Kijun Sen. Would you like me to try that?
Ответить
Gesundheit Gesundheit
@MSNEAD1992, forgot to include the Kijun Sen snapshot. It looks like the EMA crosses gave better exits than the ones I marked here:
Ответить
Домой Скринер акций Скринер форекс Скринер криптовалют Экономический календарь О проекте Особенности Цены Правила поведения Модераторы Решения для сайтов и брокеров Виджеты Графики TradingView для сайтов Справочный центр Отзывы и предложения Блог и новости ЧаВо Wiki Твиттер
Профиль Настройка профиля Счёт и оплата TradingView Coins Мои запросы в поддержку Справочный центр Опубликовано идей Подписчики Подписан Личные сообщения Чат Выйти