Trend Signal conversion from TradingView

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #106287 quote
    AlgoAlexAlgoAlex
    Participant
    Master

    https://www.tradingview.com/script/WVFF2bZZ-4X-Global-Trend-Signal/

     

    An interesting indicator, based upon cross of simulated obliques trendlines to provide entry signals.

    Hope Nicolas could use his magic once again…

    description from its author:

    When all of the sources confirm a trend (based on my criteria), the indicator draws a ‘buy’ or ‘sell’ label on the chart. This is a very simple indicator to use and it’s darn accurate. I may automate it at some point.

    This indicator does NOT repaint, but it will flash on/off during the current bar until it closes. Do NOT enter a trade until the current bar closes with a signal. You enter at the open of the succeeding candle (i.e. the candle immediately after the signal candle).

    There is only one variable to adjust; ‘Risk’. When you increase the Risk variable, you are increasing your trading risk because the indicator will not respond as fast. However, I have found that higher settings filter out the noise better.

    For me, the sweet spot seems to be on the 30 minute chart with a Risk value of ’24’. If you find additional ‘sweet spots’ for this indicator

    //@version=2
    study("Trend Signal", overlay=true)
    RISK= input(title="RISK", type=integer, defval=14)
    value10=3+RISK*2
    value11=value10
    x1=67+RISK
    x2=33-RISK
    
    range(length) =>
        sum = 0
        for i = 1 to length-1
            sum := sum + abs(high[i]-low[i])
        sum / length
    
    MRO1(length, range) =>
    	true_count = 0
    	counter = 0
    	for i = 1 to length-1
    		x = if abs(open[i]-close[i+1]) >= range*2.0
    			true_count := true_count + 1
    			counter = i
    			break
    	mro = if true_count >= 1
    		counter
    	else
    		-1	
    	mro
    
    MRO2(length, range) =>
    	true_count = 0
    	counter = 0
    	for i = 1 to length-1
    		x = if abs(close[i+3]-close[i]) >= range*4.6
    			true_count := true_count + 1
    			counter = i
    			break
    	mro = if true_count >= 1
    		counter
    	else
    		-1	
    	mro
    
    wpr(length) =>
        upper = highest(length)
        lower = lowest(length)
        out = 100 * (close - upper) / (upper - lower)
        out
    	
    rng = range(10)
    mro1=MRO1(10,rng)
    mro2=MRO2(7,rng)
    
    rez = if mro1>-1
    	3
    else
    	value10
    	
    value11:=rez
    rez1 = if mro2>-1
    	4
    else
    	value10
    value11:=rez1
    
    value2 = 100-abs(wpr(value10))
    
    Table_value2=value2
    
    notset=false
    ii1 = 1
    for i1 = 1 to 300
        if ((Table_value2[i1] < x2 or Table_value2[i1] > x1) and notset==false)
            notset:=true
            ii1 := i1
    
    z=Table_value2[ii1]
    up = if value2 < x2
        if Table_value2[ii1] > x1
            ii1
    	else
    	    0
    else
        0
    
    
    plotshape(up, style=shape.labeldown, location=location.abovebar, size=size.normal, color=aqua, text="Sell")
    
    dn = if value2 > x1
        if Table_value2[ii1] < x2
            ii1
    	else
    	    0
    else
        0
    
    
    plotshape(dn, style=shape.labelup, location=location.belowbar, size=size.normal, color=aqua, text="Buy")
    
    //plotshape(Table_value2, style=shape.arrowdown, location=location.bottom, color=white)
    //plotshape(ii1, style=shape.arrowdown, location=location.bottom, color=white)
    //plotshape(x1, style=shape.arrowdown, location=location.bottom, color=white)
    //plotshape(x2, style=shape.arrowdown, location=location.bottom, color=white)
    //plotshape(value11, style=shape.arrowdown, location=location.bottom, color=white)
    //plotshape(z, style=shape.arrowdown, location=location.bottom, color=white)
    4X-Global-Trend-Signal.jpg 4X-Global-Trend-Signal.jpg
    #106332 quote
    NicolasNicolas
    Keymaster
    Legend

    Not the first time you asked for conversion and still don’t respect the rules .. 🙄

    Please add pictures of the original indicator when requesting a conversion from another platform! I’ll add it myself to your post.

    #106350 quote
    AlgoAlexAlgoAlex
    Participant
    Master

    Sorry Nicolas, I thought the link was enough…

    #106356 quote
    NicolasNicolas
    Keymaster
    Legend

    What a mess this code is! most of the code isn’t useful.. and the other part is full of bugs :/ (that I fixed).. Anyway here is the translation:

    RISK= 14
    //value10=3+RISK*2
    //value11=value10
    x1=67+RISK
    x2=33-RISK
    
    //range function
    rnglength = 10
    rngsum=summation[rnglength](abs(high-low))
    irange=rngsum / rnglength
    
    //MRO1 function
    truecount = 0
    counter = 0
    length=10
    for i = 1 to length-1 do 
    if abs(open[i]-close[i+1]) >= irange*2.0 then 
    truecount = truecount + 1
    counter = i
    break
    endif
    next
    if truecount >= 1 then
    mro1=counter
    else
    mro1=-1
    endif
    
    //MRO2 function
    truecount = 0
    counter = 0
    length=7
    for i = 1 to length-1 do
    if abs(close[i+3]-close[i]) >= irange*4.6 then
    truecount = truecount + 1
    counter = i
    break
    endif
    next
    if truecount >= 1 then
    mro2=counter
    else
    mro2=-1
    endif
    
    wpr = Williams[10](close)
    
    if mro1>-1 then 
    //rez=3
    else
    //rez=value10
     endif
    
    //value11=rez
    if mro2>-1 then 
    //rez1=4
    else
    //rez1=value10
    endif
    //value11=rez1
    
    value2 = 100-abs(wpr)
    
    Tablevalue2=value2
    
    notset=0//false
    ii1 = 1
    for i1 = 1 to 300 do 
    if ((Tablevalue2[i1] < x2 or Tablevalue2[i1] > x1) and notset=0) then
    notset=1//true
    ii1 = i1
    break
    endif
    next
    
    //z=Tablevalue2[ii1]
    if value2 < x2 then 
    if Tablevalue2[ii1] > x1 then 
    up = ii1
    else
    up =0
    endif
    else
    up=0
    endif
    
    atr=AverageTrueRange[14](close)
    if up then 
    drawarrowdown(barindex[ii1],high[ii1]+atr) coloured(255,0,0)
    //drawtext("#ii1#",barindex[ii1],high[ii1],dialog,standard,20)
    endif
    
     if value2 > x1 then 
    if Tablevalue2[ii1] < x2 then 
    dn=ii1
    else
    dn=0
    endif
    else
    dn=0
    endif
    
    if dn then
    drawarrowup(barindex[ii1],low[ii1]-atr) coloured(0,255,0)
    endif
    
    return 
    
    AlgoAlex thanked this post
    4X-Global-Trend-Signal.png 4X-Global-Trend-Signal.png
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Trend Signal conversion from TradingView


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
AlgoAlex @alexf Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by NicolasNicolas
7 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/02/2019
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...