Range breakout code on TradingView

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #162950 quote
    Mitchy14
    Participant
    Average

    Hi all,

    I’m hoping you can help… I came across a strategy on Tradingview that I liked the look of, and believe I can develop on Daily chart as an automated strategy.

    I have been staring at this code for a while… Simply, I don’t have the coding knowledge to transfer this over to Prorealtime. Also, I think an expert eye could scrutinise the methodology (just in case I am missing something)

    I wondered if anyone would be interested in coding this? Apologies in advance if this is something you do not do.

    Link to script https://uk.tradingview.com/u/guikroth/#published-scripts

     

    //////////////////////////////////////////////////////////////////////////
    // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
    //////////////////////////////////////////////////////////////////////////
    
    
    study(title="Range Filter Buy and Sell 5min", overlay=true)
    
    // Source
    
    src = input(defval=close, title="Source")
    
    // Sampling Period
    // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
    
    per = input(defval=100, minval=1, title="Sampling Period")
    
    // Range Multiplier
    
    mult = input(defval=3.0, minval=0.1, title="Range Multiplier")
    
    // Smooth Average Range
    
    smoothrng(x, t, m)=>
        wper      = (t*2) - 1
        avrng     = ema(abs(x - x[1]), t)
        smoothrng = ema(avrng, wper)*m
        smoothrng
    smrng = smoothrng(src, per, mult)
    
    // Range Filter
    
    rngfilt(x, r)=>
        rngfilt  = x
        rngfilt := x > nz(rngfilt[1]) ? ((x - r) < nz(rngfilt[1]) ? nz(rngfilt[1]) : (x - r)) : ((x + r) > nz(rngfilt[1]) ? nz(rngfilt[1]) : (x + r))
        rngfilt
    filt = rngfilt(src, smrng)
    
    // Filter Direction
    
    upward   = 0.0
    upward  := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
    downward = 0.0
    downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
    
    // Target Bands
    
    hband = filt + smrng
    lband = filt - smrng
    
    // Colors
    
    filtcolor = upward > 0 ? lime : downward > 0 ? red : orange
    barcolor  = (src > filt) and (src > src[1]) and (upward > 0) ? lime : (src > filt) and (src < src[1]) and (upward > 0) ? green : 
       (src < filt) and (src < src[1]) and (downward > 0) ? red : (src < filt) and (src > src[1]) and (downward > 0) ? maroon : orange
    
    filtplot = plot(filt, color=filtcolor, linewidth=3, title="Range Filter")
    
    // Target
    
    hbandplot = plot(hband, color=aqua, transp=100, title="High Target")
    lbandplot = plot(lband, color=fuchsia, transp=100, title="Low Target")
    
    // Fills
    
    fill(hbandplot, filtplot, color=aqua, title="High Target Range")
    fill(lbandplot, filtplot, color=fuchsia, title="Low Target Range")
    
    // Bar Color
    
    barcolor(barcolor)
    
    // Break Outs
    
    longCond = na
    shortCond = na
    longCond := ((src > filt) and (src > src[1]) and (upward > 0)) or ((src > filt) and (src < src[1]) and (upward > 0)) 
    shortCond := ((src < filt) and (src < src[1]) and (downward > 0)) or ((src < filt) and (src > src[1]) and (downward > 0))
    
    CondIni = 0
    CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
    longCondition = longCond and CondIni[1] == -1
    shortCondition = shortCond and CondIni[1] == 1
    
    //Alerts
    
    plotshape(longCondition, title = "Buy Signal", text ="BUY", textcolor = white, style=shape.labelup, size = size.normal, location=location.belowbar, color = green, transp = 0)
    plotshape(shortCondition, title = "Sell Signal", text ="SELL", textcolor = white, style=shape.labeldown, size = size.normal, location=location.abovebar, color = red, transp = 0)
    
    alertcondition(longCondition, title="Buy Alert", message = "BUY")
    alertcondition(longCondition, title="Buy Alert", message = "BUY")
    alertcondition(longCondition, title="Buy Alert", message = "BUY")
    alertcondition(shortCondition, title="Sell Alert", message = "SELL")
    #163112 quote
    Nicolas
    Keymaster
    Master

    Same indicator as this one: Range filter but with arrows BUY/SELL when the trend change from green to red and vice-versa.

    Mitchy14 thanked this post
    #163117 quote
    Mitchy14
    Participant
    Average

    Thanks, Nicholas – I’ll check it out. Thanks for coming back so quickly (as always!!)

    #163265 quote
    Madrosat
    Participant
    Master

    Bonjour comment créer un signal au changement de couleur du Range filter?? Ou comment créer un screener qui détecte ces changements??

    Hello, how do you create a signal when the Range filter changes color ?? Or how do you create a screener that detects these changes?

    #163284 quote
    Vonasi
    Moderator
    Master

    Madrosat – English only in the English speaking forums please.

    #163294 quote
    Madrosat
    Participant
    Master

    Vonasi
    the automatic translator being activated, everything was written in French.
    It’s good to have fun rectifying but it’s better to answer my question

    #163309 quote
    Vonasi
    Moderator
    Master

    Fixing posted errors is no fun at all. Everyone has five minutes after submitting a post to delete it or edit it and it would be helpful if forum members could double check what they have submitted to ensure that it is correct before leaving the page. This would considerably help moderators reduce their workload keeping the forums tidy and leave them with more time to answer questions.

    As for your question – do you not think that if I knew the answer I would have given it? I did not create the indicator, I have never used the indicator and I know nothing about the indicator. I do however know the difference between French and English so can tell you when you have posted in the wrong language… but it is better if I don’t have to. 😉

    #163421 quote
    Nicolas
    Keymaster
    Master
    #163510 quote
    Madrosat
    Participant
    Master

    Thank you Nicolas

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Range breakout code on TradingView


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mitchy14 @mitchy14 Participant
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by Madrosat
4 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/02/2021
Status: Active
Attachments: No files
Logo Logo
Loading...