Daveatt

BEST Supertrend Strategy

Hello traders

Sharing a sample Supertrend strategy to illustrate how to calculate a convergence and using it in a strategy

I based the setup as follow:

- Entries on Supertrend MTF breakout + moving average cross. Entering whenever there is a convergence
- exit whenever a Simple Moving Averages cross in the opposite direction happen
- possibility to filter only Longs/Shorts or both


All the best
Dave
Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?
💰 Results/Blogs: https://bit.ly/2ULUtjo

⏩ Signals/Pricing: https://best-trading-indicator.com/pages/pricing

🐦 Twitter: https://twitter.com/bti_trading

👉 Get a $30 discount on TradingView: https://bit.ly/2UM5OA0

📺 Youtube: https://bit.ly/3bKvnZu

Комментарии

great! Is it possible to configure surendrend in hours or minutes timeframes?
+4 Ответить
Daveatt zorak2d
@zorak2d, you mean having an hourly supertrend on a different chart timeframe?
Ответить
hi @Daveatt, I tried to change the code to insert supertrend in 30, 60 and 120 minutes, however I failed. Do you have any clue or even give a hand on that try?
Ответить
Daveatt leonardoabad
@leonardoabad, probably too many things to change for that
Better to start from a strategy template from scratch, and implement the supertrend function without the security function AND just adding resolution="" in the strategy(....) function
Ответить
Coolbeans !
+4 Ответить
Tried this script and the entries on real time got repainted after refreshing and moved to an earlier time. This is because of presence of "lookahead=true" argument in the security function. To get realistic results during back testing, one should change the specific arguments to " lookahead =false". However this script has good educational value. Thanks
+1 Ответить
Daveatt bandy99
@bandy99, excellent comment
this is an old script
To avoid repainting with live data, we can use security functions as explained here:

// ————— SILVER (BEST): Uses only one `security()` call but allows repainting control.
//          - Cannot be used when the source is a tuple-returning function (use the following method then).
//          The first three parameters are the same as those of `security()`. 
//          The last one: `_rep`, must be a boolean (true/false) value. It indicates if you want repainting (true) or not (false).
//▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
f_security(_sym, _res, _src, _rep) => security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
//▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
c1 = f_security(ticker, i_timeframe, i_source, i_repaint)
plot(c1, "c1: 👍 `f_security()`", color.silver, 14)

// ————— SILVER (BEST for tuples): Technique providing the functional equivalent of `f_security()` for use with functions returning a tuple.
f_oc(_offset) => 
    // int _offset: the first half of the offset calcs required to achieve repainting/non-repainting.
    //              The second half will be handled post `security()` call, by indexing the received tuple values in a variable reassignment.
    _o = open[_offset]
    _c = close[_offset]
    [_o, _c]
[o_, c_] = security(ticker, i_timeframe, f_oc(not i_repaint and barstate.isrealtime ? 1 : 0))
o = o_[i_repaint or barstate.isrealtime ? 0 : 1]
c = c_[i_repaint or barstate.isrealtime ? 0 : 1]
c2 = c
plot(c2, "c2: 👍 Tuple form", color.fuchsia, 8)
Ответить