reees

Addressing blind hatred for indicator repainting

reees 업데이트됨   
INDEX:BTCUSD   비트코인
Since publishing the Harmonic Pattern Detection, Prediction, and Backtesting Tool, I'm constantly asked if it "repaints". For some reason, people have this deep fear of repainting, as if any indicator that repaints is some evil entity created by the devil himself, sent to earth to trick you into making bad trades. In fact I'm convinced that those most obsessed with repainting don't even actually know what repainting means. And I have news for you: the vast majority of scripts repaint, and there are only a handful of cases where non-repainting scripts are even remotely useful.

After reading a comment describing my Harmonics indicator as a "fraud", I was offended deeply enough to waste my time creating this ancillary documentation describing how the indicator "repaints".

Q: When are completed patterns drawn?

Completed patterns are drawn as soon as they are valid/confirmed, according to your settings.

If "Enter after point C" is selected, a pattern is drawn:
(1) Only if the incomplete pattern score is above your defined "If score is above" setting.
(2) As soon as price hits your defined "Enter at" PRZ level

If "Enter after point D" is selected, a pattern is drawn:
(1) As soon as the pattern is valid, as defined in your "Pattern validation length" setting. This is set to 1 by default, which means that the pattern will be drawn 1 bar after point D. This doesn't mean the script is being deceptive by drawing a pattern "in the past", it's simply drawing the pattern as soon as it's been validated. Any signal worth its weight in piss needs to be validated in some way or another, which usually takes some amount of time. It's not magic.
(2) Only if the completed pattern score is above your defined "If score is above" setting
(3) Only if price is within your defined "Enter at limit % away from D" AND on a bar within your defined "Entry window (time limit)" settings.

Q: Are completed patterns RE-drawn?
There are certain cases where we redraw a pattern when a new point D forms. The essence of a pattern is points XABC, and point D is fluid within the Potential Reversal Zone. By drawing a new point D, the script isn't being desceptive, but simply trying to give the most valuable/up-to-date information it has at the time. This repainting is done in good faith, as it respects any entries and targets that may have already been hit and doesn't affect the backtesting results in any way.

Q: When are completed patterns redrawn?
Basically, if a new point D forms for the same XABC of the same pattern type, we run some checks to determine if we should keep the old pattern, or draw a new pattern.
- If a target has already been hit, we keep the old pattern AND draw the new pattern.
- If no target has been hit, we will display the higher scoring of the two patterns.
- If there was already an entry hit on the initial pattern, that entry will be inherited by the new pattern, so it upholds the integrity of backtesting. I'm pasting this logic below for anyone who wants to see exactly what it's doing but is too lazy to look at the open source code.

A picture is worth a thousand words, so here's an example:

Isn't it better to see the new pattern with a better point D instead of keeping the old/weaker pattern? Now we have updated information, and adjusted targets relative to a higher scoring point D. If you had missed the entry on the initial pattern, wouldn't you want to know that now we have an even stronger pattern?


Point D redraw code:
// Add pattern to completed pattern structures
addValidPattern(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY,dX,dY) =>
    string[] s = na
    bool lasteH = na
    int lasteX = na
    float lasteY = na
    float lastScore = na
    tp = tp(h1,h2,h3,h4,h5,h6)
    m = typeToMatrix(t,tp)
    if matrix.rows(m) > 0
        // check last pattern of same type
        last = matrix.row(m,matrix.rows(m)-1)
        [lt,lh1,lh2,lh3,lh4,lh5,lh6,lxX,lxY,laX,laY,lbX,lbY,lcX,lcY,ldX,ldY,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,lt1H,lt2H,leH,leX,leY,lscore] 
         = unstringify(last)
        lastScore := lscore
        // if A, B or C is different = new pattern
        if aX!=laX or bX!=lbX or cX!=lcX
            s := stringify(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY,dX,dY)
            addCompleted(t,h1,h2,h3,h4,h5,h6,s)            
        // if ABC are same but D is beyond last pattern's D, replace it with this one. We want to draw the
        // new/updated pattern and calculate its updated score, but maintain any entry/targets that have
        // already been hit.
        else if (t and dY < ldY) or (t==false and dY > ldY)
            if leH and na(lt1H)
                lasteH := true     // inherit entry from last pattern (trade is active)
                lasteX := leX
                lasteY := leY
                s := stringify(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY,dX,dY,lt1H,lt2H,leH,leX,leY)
            else
                s := stringify(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY,dX,dY)
            //
            if lastScore > getScore(s)  // if lower score, keep last pattern
                s := na
            else if not na(lt1H)        // if last pattern trade closed, just add the new pattern
                addCompleted(t,h1,h2,h3,h4,h5,h6,s)
            else                        // else, remove the last pattern in favor of the new one
                lpid = pid(tp,lxX,laX,lbX,lcX,ldX)
                removeCompleted(lpid,t,tp)
                addCompleted(t,h1,h2,h3,h4,h5,h6,s)
    else
        s := stringify(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY,dX,dY)
        addCompleted(t,h1,h2,h3,h4,h5,h6,s)

    // Update newly added pattern
    if not na(s)
        // update entry, if necessary
        if lasteH
            draw.eHitLbl(lasteX,lasteY,dX,dY,t,true)
        else
            score = getScore(s)
            [eHit,eX,eY] = entryHit(t,tp,xX,cX,xY,aY,bY,cY,dX,dY,score)
            if eHit
                draw.eHitLbl(eX,eY,dX,dY,t)
                pid = pid(tp,xX,aX,bX,cX,dX)
                s := setEntry(s,eHit,eX,eY)
                l = updateCompleted(pid,t,tp,s)
코멘트:
Note: Incomplete/Potential pattern repainting is a bit more complicated, and will be addressed after I iron out a few remaining issues.
코멘트:
CORRECTION: Patterns after a valid point D will be drawn regardless of whether the score meets the "If score is above" entry requirement. That requirement only applies to entering a trade. If the score does not meet the entry requirement, we will show the "no entry" icon on the label to indicate that a trade has not/will not be entered for this pattern. The reason we still draw the pattern is so that you know it exists, and can use that information to refine your settings. e.g. maybe you decide that your "If entry is above" requirement is to restrictive, and want to include lower scoring patterns.
코멘트:
코멘트:
A note on real-time bar repainting:
Patterns can be repainted during real-time bars until the close of the last validation length bar (defined in the "Pattern validation length" setting). The default value is 1, meaning that a pattern may be redrawn on 1 real-time bar after Point D, until that bar closes. After that bar has closed, a completed pattern will not repaint (with the exception of the scenario described above).

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.