Conversion of SP Indicator useThinkScript community page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #243630 quote
    gp38supergp38super
    Participant
    New

    #// Indicator for TOS
    #// © Smoker024
    #indicator(“SP Indicator”, overlay=true)
    # Converted by Sam4Cok@Samer800 – 10/2024

    input showBands = yes;
    input source = close;
    input lookback = 60;
    input multi = 0.2;

    def na = Double.NaN;
    def exitLength = RoundUp(lookback / 4, 0);

    Script ma {
    input src = close;
    input len = 15;
    def sqLen = Round(sqrt(len), 0);
    def wma1 = wma(src, len);
    def wma2 = wma(src, len / 2);
    def ma = wma(2 * wma2 – wma1, sqLen);
    plot out = ma;
    }
    def tr = TrueRange(high, close, low);
    def BBMC = ma(source, lookback);
    def rangema = ExpAverage(tr, lookback);
    def upperk =BBMC + rangema * multi;
    def lowerk = BBMC – rangema * multi;
    def col = if source > upperk then 1 else if source < lowerk then -1 else 0;

    def ExitHigh = ma(high, exitLength);
    def ExitLow = ma(low, exitLength);
    def Hlv3 = if source > ExitHigh then 1 else if source < ExitLow then -1 else Hlv3[1];
    def sslExit = if Hlv3 < 0 then ExitHigh else ExitLow;
    def base_cross_Long = (close > sslExit) and (close[1] <= sslExit[1]);
    def base_cross_Short = (sslExit > close) and (sslExit[1] <= close[1]);
    def codiff = if base_cross_Long then 1 else if base_cross_Short then -1 else 0;

    plot ExitArrowUp = if codiff>0 then low else na;
    plot ExitArrowDn = if codiff<0 then low else na;
    plot maTrendLine = BBMC; # ‘MA Trendline’
    plot limitUp = if showBands then upperk else na;
    plot limitDn = if showBands then lowerk else na;

    maTrendLine.SetLineWeight(2);
    maTrendLine.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
    limitUp.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
    limitDn.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
    ExitArrowUp.SetDefaultColor(Color.CYAN);
    ExitArrowDn.SetDefaultColor(Color.MAGENTA);
    ExitArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
    ExitArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

    Plots Up and Down arrows

     

    Variable options:

    #243635 quote
    LucasBestLucasBest
    Participant
    Senior
    #243731 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Here it is:

    //---------------------------------------//
    //PRC_SP Indicator
    //version = 1
    //11.02.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //---------------------------------------//
    // inputs
    //---------------------------------------//
    src=close
    len=60
    //---------------------------------------//
    // Moving Average and Bands
    //---------------------------------------//
    bbmc=average[max(1,round(sqrt(len))),2](average[max(1,round(len/2)),2](src)*2-average[len,2](src))
    rangema=average[len,1](tr)
    upperk=bbmc+rangema*0.2
    lowerk=bbmc-rangema*0.2
    //---------------------------------------//
    // Colors Definition
    //---------------------------------------//
    if close>upperk then
    r=33
    g=150
    b=243
    elsif close<lowerk then
    r=225
    g=64
    b=251
    else
    r=120
    g=123
    b=134
    endif
    drawcandle(open,high,low,close)coloured(r,g,b)
    //---------------------------------------//
    // Signals 
    //---------------------------------------//
    srcH=high
    lenH=15
    ExitHigh=average[max(1,round(sqrt(lenH))),2](average[max(1,round(lenH/2)),2](srcH)*2-average[lenH,2](srcH))
    srcL=low
    lenL=15
    ExitLow=average[max(1,round(sqrt(lenL))),2](average[max(1,round(lenL/2)),2](srcL)*2-average[lenL,2](srcL))
    
    if close>ExitHigh then
    Hlv3=1
    elsif close<ExitLow then
    Hlv3=-1
    endif
    
    if Hlv3<0 then
    sslExit=ExitHigh
    else
    sslExit=ExitLow
    endif
    
    baseCrossLong=close crosses over sslExit
    baseCrossShort=close crosses under sslExit
    
    if baseCrossLong then
    codiff=1
    drawarrowup(barindex,low-rangema*0.5)coloured(33,150,243)
    elsif baseCrossShort then
    codiff=-1
    drawarrowdown(barindex,high+rangema*0.5)coloured(225,64,251)
    else
    codiff=1=undefined
    endif
    //---------------------------------------//
    return bbmc coloured(r,g,b)style(line,2)
    LaMaille thanked this post
    #243736 quote
    LaMailleLaMaille
    Participant
    Junior

    I took the liberty of making a few changes to it, in order to make it little bit faster… at least i tried 🙂

    //---------------------------------------//
    //PRC_SP Indicator
    //version = 1
    //11.02.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //---------------------------------------//
    // inputs
    //---------------------------------------//
    src=close
    once len=60
    once sqrtlen = round(sqrt(len))
    //---------------------------------------//
    // Moving Average and Bands
    //---------------------------------------//
    bbmc=average[sqrtlen,2](average[round(len/2),2](src)*2-average[len,2](src))
    rangema=average[len,1](tr)
    upperk=bbmc+rangema*0.2
    lowerk=bbmc-rangema*0.2
    //---------------------------------------//
    // Colors Definition
    //---------------------------------------//
    if close>upperk then
    r=33
    g=150
    b=243
    elsif close<lowerk then
    r=225
    g=64
    b=251
    else
    r=120
    g=123
    b=134
    endif
    drawcandle(open,high,low,close)coloured(r,g,b)
    //---------------------------------------//
    // Signals
    //---------------------------------------//
    //srcH=high
    once lenH = 15
    once sqrtlenH = round(sqrt(lenH))
    ExitHigh=average[sqrtlenH,2](average[round(lenH/2),2](high)*2-average[lenH,2](high))
    //srcL=low
    once lenL = 15
    once sqrtlenL = round(sqrt(lenL))
    ExitLow=average[sqrtlenL,2](average[round(lenL/2),2](low)*2-average[lenL,2](low))
     
    if close>ExitHigh then
    Hlv3=1
    elsif close<ExitLow then
    Hlv3=-1
    endif
     
    if Hlv3<0 then
    sslExit=ExitHigh
    else
    sslExit=ExitLow
    endif
     
    baseCrossLong=close crosses over sslExit
    baseCrossShort=close crosses under sslExit
     
    if baseCrossLong then
    codiff=1
    drawarrowup(barindex,low-rangema*0.5)coloured(33,150,243)
    elsif baseCrossShort then
    codiff=-1
    drawarrowdown(barindex,high+rangema*0.5)coloured(225,64,251)
    else
    codiff=1=undefined
    endif
    //---------------------------------------//
    return bbmc coloured(r,g,b,100)style(line,5)
    #243765 quote
    gp38supergp38super
    Participant
    New

    Sorry for the delay in replying, but Thank you! Both look fantastic!

Viewing 5 posts - 1 through 5 (of 5 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

Conversion of SP Indicator useThinkScript community page


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
gp38super @gp38super Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by gp38supergp38super
1 year, 7 months ago.

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