TradingView
ramki_simple
30 May 2021 17:14

Multi Supertrend with no-repaint HTF option strategy 

Ethereum / TetherUSBinance

Açıklama

This is the strategy version of the multi supertrend indicator.
The RoMDD looks good :)
Checked in ETHUSDT 1hour with auto HTF ON.
Have a look :)
Yorumlar
Aditya_Jaiswal05
why have you used " lookahead = barmerge.lookahead_on " it will lead repaint and show desirable results that when applied in real time would act and work differently.
Please don't mislead people here.
ramki_simple
@Wydinij485, Apologies for the late reply bro, actually, this is a trick to get a stable non-repaint output.

Add this code on a 1 min chart,

//@version=4
study("My Script", overlay=true)
f_Security(_symbol, _res, _src) => security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
plot(f_Security(syminfo.tickerid,'5',close),color=color.navy) //stable output without repaint
plot(security(syminfo.tickerid,'5',close),color=color.black) //instable output and repainting to old
plot(security(syminfo.tickerid,'5',close, lookahead = barmerge.lookahead_on),color=color.silver) //instable output and repainting to future

--------
For every curve we try to describe, we need to keep track of few things:

- A : 5 min candle close(HTF)
- B : 1 min candle close
- C : curve output in 1 min timeframe

We will refer to them as A, B and C to simplify things.
"A(12:10)" means close of 5 min candle at 12:10. This is representing time from 12:10:00 to 12:14:59

--------
Let us study each curve. First, we will look at the black curve
security(syminfo.tickerid,'5',close)// we will call this C

When you plot this, you will immediately see a curve plotting the last closed candle in 5 min, our HTF.
It is flat at this value, till, we see a new close in HTF.

If you notice carefully, after the indicator is plotted, you are seeing an unstable output, wiggly end points.
It trying to approximate the latest close, even before it has closed.

Once the HTF candle has closed. For example, C(12:14) aligns with A(12:10) . We will see the black line latching on the close.
Also, the wiggly line is now flat. Means, it has repainted. If it has not, just refresh your chart and you will get a perfect curve.
For example, 1 min timeframe 12:12 candle black curve, C(12:12) is repainted to A(12:05), that we already know as B(12:09).
If you notice, C(12:12) repainted to a value we knew at 12:10.

--------
Now we will consider the silver curve
security(syminfo.tickerid,'5',close, lookahead = barmerge.lookahead_on)//we will call this D

If you notice, carefully, in a few 1 min candles, you will see that, the wiggly values of the black and the silver curve is the same.
When the HTF candle is closed, it is repainted to be looking ahead, in the sense that, we repaint D(12:10) through D(12:14) to A(2:10).
Note that, B(12:14) is same as A(12:10), this value is used for D(12:12). This data was not available at 12:12

So, we have seen 2 kinds of repainting at 12:12 candle. Black curve is repainting to known value, while silver curve is repainting to values unavailable at that time.

Ideally, we want to be as close as possible to the repainted black curve, latest data, but, without the repainting.

-------
Here comes in the blue curve,
security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)

Notice, the output is delayed from black curve by a 1 min candle, but, output is stable.
To put it tersely, "it is repainting to same known value".
Please, work that out as an exercise.
ramki_simple
@ramki_simple, There is a typo.
Read "we repaint D(12:10) through D(12:14) to A(2:10)."
as "we repaint D(12:10) through D(12:14) to A(12:10)."

Typed the wrong time
ramki_simple
@ramki_simple, oh my god, the security function is printed wrong, even the blue curve is typed wrong.
ramki_simple
@ramki_simple, somehow, the comment field is skipping, \square_bracket 1 \square_bracket_close in the source field, please refer to the published code for correct f_Security function. Square bracket is not working.
gauravcisfboby82
Hi I want talk with u .I have some work for u ..can u contact me ..my mail ID is ..gauravcisf.boby82@gmail.com. plz give ur contact
allanster
@Wydinij485, the author's custom function for security is correct and does not repaint because it calls the PREVIOUS bar's source AND uses barmerge.lookahead_on:

repaint = security(syminfo.tickerid, "D", close) noRepaint = security(syminfo.tickerid, "D", close‎‎BRACKET 1 BRACKET, lookahead = barmerge.lookahead_on)

I would encourage you to see the following scripts for further info:
tradingview.com/script/cyPWY96u-How-to-avoid-repainting-when-using-security-PineCoders-FAQ/
tradingview.com/script/00jFIl5w-security-revisited-PineCoders/
MrWickTrading
@allanster, So just to confirm - this script does not repaint?
allanster
@TheOneTradingIndicator, based off of the current code above using the function in line 38 there should be no repaint when using a higher timeframe. The function calls the previous higher timeframe bar. For further reference see:
tradingview.com/pine-script-docs/en/v5/concepts/Repainting.html
MrWickTrading
Hi, is there a way to change the alert messages? Thanks
Daha Fazla