School Run style strategy indicator to Pro Build

Forums ProRealTime English forum ProBuilder support School Run style strategy indicator to Pro Build

Viewing 7 posts - 1 through 7 (of 7 total)
  • #242549

    Hello everyone.
    Thank you for this amazing resource.  What a great place on the internet.

    I have a pine script indicator that my friend has written for Trading View and we are wanting to backtest further with ProReal Time.

    Can anyone do a conversion of this script please?

    If there’s any possibillity of adding Day of the week and Date to the label I would be most grateful but i’d be very happy with just the conversion if its not possible.

    Mega thanks.

    Darren

     

    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © fx_huebner
    //@version=5
    indicator(title=”RR Lines_V3″, overlay=true, precision = 3)
    //Input Options Full / Half / custom
    cfRangeLong = input.bool(false, “CR_Full Long”)
    cfRangeShort = input.bool(false, “CR_Full Short”)
    chRangeLong = input.bool(false, “CR_Half Long”)
    chRangeShort = input.bool(false, “CR_Half Short”)
    // Slippage for stop loss
    slippage = input.float(0.06,”Padding”, inline= “B” )
    //Time Options Input
    // First to take care of the time. There isn’t a function for this without the date as well, so I just made my own.
    i_hour = input.int(1, “Time (HH:mm)”,0, 23, 1, inline = “A”)
    i_minute = input.int(0, “:”,0, 59, 1, inline = “A”)
    // Then we need to create the options for the different days of the week. This allows for the most customization.
    i_sunday = input.bool(true, “Sunday”)
    i_monday = input.bool(true, “Monday”)
    i_tuesday = input.bool(true, “Tuesday”)
    i_wednesday = input.bool(true, “Wednesday”)
    i_thursday = input.bool(true, “Thursday”)
    i_friday = input.bool(true, “Friday”)
    i_saturday = input.bool(true, “Saturday”)
    start = input.time(timestamp(“01 Jan 2024 12:00 UTC+0”), “Start”)
    end = input.time(timestamp(“25 Jan 2024 12:00 UTC+0”), “End”)
    // Parameters
    candleRange = (high-low)
    customRange = (high + slippage)
    customRangeL = (low – slippage)
    halfRange = (candleRange / 2)
    slipRange = (candleRange + slippage)
    halfSlipRange = ((candleRange/2)+slippage)
    //candleHigh = (high +0.02)
    //candleLow = (low – 0.02)
    //halfSlipRange = ((high + slippage) – (high – halfRange))
    //@variable Checks the time of the candle and gets the day of the week as represented by numbers 1-7, starting on Sunday.
    todayDay = dayofweek(time)
    // Define Time for Candle
    // Rewrote this function so that it does the same thing but now will use the variables from above.
    candleTime(_hour, _mins) =>
    // Created 2 variables that need to be true in order to return true.
    isTimeMatch=hour==_hourandminute==_mins
    isTodayShown=switchtodayDay
    1=>i_sunday
    2=>i_monday
    3=>i_tuesday
    4=>i_wednesday
    5=>i_thursday
    6=>i_friday
    7=>i_saturday
    isTimeMatchandisTodayShown
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////// Custom Range //////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////// CR Full Long///////////////////////////////////////////////////////////////////////
    if time >= start and time <= end and candleTime(i_hour, i_minute) and (cfRangeLong == true)
    //Buy Price
    line.new(x1=time,y1=high+slippage+0.01,x2=time+86400000,y2=high+slippage+0.01,xloc=xloc.bar_time,color=color.yellow,style=line.style_dashed),
    rrEntrycfRangeLongLabel=label.new (x=bar_index,y=high+slippage+0.01,color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(Buy) “+str.tostring (high+slippage+0.01,’#.000′)),
    line.new(x1=time,y1=high+slippage,x2=time+1800,y2=high+slippage,xloc=xloc.bar_time,color=color.green,style=line.style_dashed),
    // Stop Loss
    line.new(x1=time,y1=low-0.01,x2=time+86400000,y2=low-0.01,xloc=xloc.bar_time,color=color.white,style=line.style_dashed)
    rrSlcfRangeLongLabel=label.new (x=bar_index,y=low-0.01,color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(SL) “+str.tostring (low-0.01,’#.000′))
    line.new(x1=time,y1=low,x2=time+900,y2=low,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    //1:1.5
    line.new(x1=time,y1=customRange+ (slipRange*1.5),x2=time+86400000,y2=customRange+ (slipRange*1.5),xloc=xloc.bar_time,style=line.style_dashed)
    rr1_5cfRangeLongLabel=label.new (x=bar_index,y= (high+slippage) + (slipRange*1.5),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(1.5) “+str.tostring ((high+slippage) + (slipRange*1.5),’#.000′))
    //2:1
    line.new(x1=time,y1= (high+slippage) + (slipRange*2),x2=time+86400000,y2= (high+slippage) + (slipRange*2),xloc=xloc.bar_time,style=line.style_dashed)
    rrcfRangeLongLabel=label.new (x=bar_index,y= (high+slippage) + (slipRange*2),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(2) “+str.tostring ((high+slippage) + (slipRange*2),’#.000′))
    //Take Profit 3:1
    line.new(x1=time,y1= (high+slippage) + (slipRange*3),x2=time+86400000,y2= (high+slippage) + (slipRange*3),xloc=xloc.bar_time,color=color.orange,style=line.style_dashed)
    rr3cfRangeLongLabel=label.new (x=bar_index,y= (high+slippage) + (slipRange*3),color=color.blue,style=label.style_none,size=size.small,textcolor=color.orange,text_font_family=font.family_monospace,text=”(3) “+str.tostring ((high+slippage) + (slipRange*3),’#.000′)),
    //To the moon 14:1
    //line.new(x1=time, y1= high + (slipRange*14), x2=time + 86400000, y2= high + (slipRange*14), xloc=xloc.bar_time, color = color.white, style = line.style_dashed)
    //rr14cfRangeLongLabel = label.new (x=bar_index, y = high + (slipRange*14), color=color.blue, style=label.style_none, size=size.small,textcolor = color.orange, text_font_family = font.family_monospace, text = “(14) ” + str.tostring (high + (slipRange*14),’#.000′)),
    //13:1
    //line.new(x1=time, y1= high + (slipRange*13), x2=time + 86400000, y2= high + (slipRange*13), xloc=xloc.bar_time, color = color.white, style = line.style_dashed)
    //rr13cfRangeLongLabel = label.new (x=bar_index, y = high + (slipRange*13), color=color.blue, style=label.style_none, size=size.small,textcolor = color.orange, text_font_family = font.family_monospace, text = “(13) ” + str.tostring (high + (slipRange*13),’#.000′)),
    myLabel=label.new(x=bar_index,y=high,color=color.white,
    style=label.style_label_up,size=size.small,
    text=
    “H: “+str.tostring(high) +
    “\nL: “+str.tostring(low) +
    “\nR: “+str.tostring(candleRange) +
    “\nHR: “+str.tostring((low+halfRange) ))
    //”\nSS: ” + str.tostring(high + 0.07))
    // Modify the label’s y-axis behaviour; show it below the price bar
    label.set_yloc(id=myLabel,yloc=yloc.belowbar)
    //////////////////////////////////////////////////////////////////////// CR Full Short //////////////////////////////////////////////////////////////////////////////////////////
    if time >= start and time <= end and candleTime(i_hour, i_minute) and (cfRangeShort == true)
    // Buy Price
    line.new(x1=time,y1=low-slippage-0.01,x2=time+86400000,y2=low-slippage-0.01,xloc=xloc.bar_time,color=color.yellow,style=line.style_dashed)
    rrEntrycfRangeShortLabel=label.new (x=bar_index,y= (low-slippage-0.01),color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(BUY) “+str.tostring (low-slippage-0.01,’#.000′))
    line.new(x1=time,y1=low-slippage,x2=time+900,y2=low-slippage,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    //Stop Loss
    line.new(x1=time,y1=high+0.01,x2=time+86400000,y2=high+0.01,xloc=xloc.bar_time,color=color.white,style=line.style_dashed)
    rrSlcfRangeShortLabel=label.new (x=bar_index,y=high+0.01,color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(SL) “+str.tostring (high+0.01,’#.000′))
    line.new(x1=time,y1=high,x2=time+900,y2=high,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    // 1:1.5
    line.new(x1=time,y1=customRangeL- (slipRange*1.5),x2=time+86400000,y2=customRangeL- (slipRange*1.5),xloc=xloc.bar_time,style=line.style_dashed)
    rr1_5cfShortLabel=label.new (x=bar_index,y=customRangeL- (slipRange*1.5),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(1.5) “+str.tostring (customRangeL- (slipRange*1.5),’#.000′))
    //2:1
    line.new(x1=time,y1=customRangeL- (slipRange*2),x2=time+86400000,y2=customRangeL- (slipRange*2),xloc=xloc.bar_time,style=line.style_dashed)
    rr2cfShortLabel=label.new (x=bar_index,y=customRangeL- (slipRange*2),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(2) “+str.tostring (customRangeL- (slipRange*2),’#.000′))
    // 3:1 Take Profit
    line.new(x1=time,y1=customRangeL- (slipRange*3),x2=time+86400000,y2=customRangeL- (slipRange*3),xloc=xloc.bar_time,color=color.orange,style=line.style_dashed)
    rr3cfShortLabel=label.new (x=bar_index,y=customRangeL- (slipRange*3),color=color.orange,style=label.style_none,size=size.small,textcolor=color.orange,text_font_family=font.family_monospace,text=”(3) “+str.tostring (customRangeL- (slipRange*3),’#.000′))
    // To the moon 4:1
    //line.new(x1 = time, y1 = low – (candleRange*4), x2 = time + 86400000, y2 = low – (candleRange*4), xloc = xloc.bar_time),
    myLabel=label.new(x=bar_index,y=high,color=color.white,
    style=label.style_label_down,size=size.small,
    text=
    “H: “+str.tostring(high) +
    “\nL: “+str.tostring(low) +
    “\nR: “+str.tostring(candleRange,’#.000′) +
    “\nHR: “+str.tostring((low+halfRange )))
    //”\nSS: ” + str.tostring(high + 0.07))
    // Modify the label’s y-axis behaviour; show it below the price bar
    label.set_yloc(id=myLabel,yloc=yloc.abovebar)
    ////////////////////////////////////////////////////////////// CR Half Long ////////////////////////////////////////////////////////////////////////////////
    if time >= start and time <= end and candleTime(i_hour, i_minute) and (chRangeLong == true)
    // Buy Price
    line.new(x1=time,y1=high+slippage+0.01,x2=time+86400000,y2=high+slippage+0.01,xloc=xloc.bar_time,color=color.yellow,style=line.style_dashed)
    rrEntrychRangeLongLabel=label.new (x=bar_index,y= (high+slippage+0.01),color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(BUY) “+str.tostring (high+slippage+0.01,’#.000′))
    line.new(x1=time,y1=high+slippage,x2=time+900,y2=high+slippage,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    //Stop Loss
    line.new(x1=time,y1=high-halfRange-0.01,x2=time+86400000,y2=high-halfRange-0.01,xloc=xloc.bar_time,color=color.white,style=line.style_dashed)
    rrSlchRangeLongLabel=label.new (x=bar_index,y= (high-halfRange-0.01),color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(SL) “+str.tostring (high-halfRange-0.01,’#.000′))
    line.new(x1=time,y1=high-halfRange,x2=time+900,y2=high-halfRange,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    // 1:1.5
    line.new(x1=time,y1=customRange+ (halfSlipRange*1.5),x2=time+86400000,y2=customRange+ (halfSlipRange*1.5),xloc=xloc.bar_time,style=line.style_dashed)
    rr1_5chRangeLongLabel=label.new (x=bar_index,y=customRange+ (halfSlipRange*1.5),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(1.5) “+str.tostring (customRange+ (halfSlipRange*1.5),’#.000′))
    //2:1
    line.new(x1=time,y1=customRange+ (halfSlipRange*2),x2=time+86400000,y2=customRange+ (halfSlipRange*2),xloc=xloc.bar_time,style=line.style_dashed)
    rr2chRangeLongLabel=label.new (x=bar_index,y=customRange+ (halfSlipRange*2),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(2) “+str.tostring (customRange+ (halfSlipRange*2),’#.000′))
    // 3:1 Take Profit
    line.new(x1=time,y1=customRange+ (halfSlipRange*3),x2=time+86400000,y2=customRange+ (halfSlipRange*3),xloc=xloc.bar_time,color=color.orange,style=line.style_dashed)
    rr3chRangeLongLabel=label.new (x=bar_index,y=customRange+ (halfSlipRange*3),color=color.blue,style=label.style_none,size=size.small,textcolor=color.orange,text_font_family=font.family_monospace,text=”(3) “+str.tostring (customRange+ (halfSlipRange*3),’#.000′)),
    // To the moon 4:1
    //line.new(x1 = time, y1 = high + (halfRange*4), x2 = time + 86400000, y2 = high + (halfRange*4), xloc = xloc.bar_time),
    myLabel=label.new(x=bar_index,y=high,color=color.white,
    style=label.style_label_up,size=size.small,
    text=
    “H: “+str.tostring(high) +
    “\nL: “+str.tostring(low) +
    “\nR: “+str.tostring(candleRange) +
    “\nHR: “+str.tostring(low+halfRange))
    //”\nSS: ” + str.tostring(high + 0.07))
    // Modify the label’s y-axis behaviour; show it below the price bar
    label.set_yloc(id=myLabel,yloc=yloc.belowbar)
    /////////////////////////////////////////////////////////////////////////////// CR Half Short //////////////////////////////////////////////////////////////////////////////
    if time >= start and time <= end and candleTime(i_hour, i_minute) and (chRangeShort == true)
    // Buy Price
    line.new(x1=time,y1=customRangeL-0.01,x2=time+86400000,y2=customRangeL-0.01,xloc=xloc.bar_time,color=color.yellow,style=line.style_dashed)
    rrEntrychRangeShortLabel=label.new (x=bar_index,y=customRangeL-0.01,color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(BUY) “+str.tostring (customRangeL-0.01,’#.000′))
    line.new(x1=time,y1=customRangeL,x2=time+900,y2=customRangeL,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    //Stop Loss
    line.new(x1=time,y1=low+halfRange+0.01,x2=time+86400000,y2=halfRange+low+0.01,xloc=xloc.bar_time,color=color.white,style=line.style_dashed)
    rrSlchRangeShortLabel=label.new (x=bar_index,y= (low+halfRange+0.01),color=color.blue,style=label.style_none,size=size.small,textcolor=color.white,text_font_family=font.family_monospace,text=”(SL) “+str.tostring (low+halfRange+0.01,’#.000′))
    line.new(x1=time,y1=low+halfRange,x2=time+900,y2=halfRange+low,xloc=xloc.bar_time,color=color.green,style=line.style_dashed)
    // 1:1.5
    line.new(x1=time,y1=customRangeL- (halfSlipRange*1.5),x2=time+86400000,y2=customRangeL- (halfSlipRange*1.5),xloc=xloc.bar_time,style=line.style_dashed)
    rr1_5chRangeShortLabel=label.new (x=bar_index,y=customRangeL- (halfSlipRange*1.5),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(1.5) “+str.tostring (customRangeL- (halfSlipRange*1.5),’#.000′)),
    //2:1
    line.new(x1=time,y1=customRangeL- (halfSlipRange*2),x2=time+86400000,y2=customRangeL- (halfSlipRange*2),xloc=xloc.bar_time,style=line.style_dashed)
    rr2chRangeShortLabel=label.new (x=bar_index,y=customRangeL- (halfSlipRange*2),color=color.blue,style=label.style_none,size=size.small,textcolor=color.blue,text_font_family=font.family_monospace,text=”(2) “+str.tostring (customRangeL- (halfSlipRange*2),’#.000′)),
    // 3:1 Take Profit
    line.new(x1=time,y1=customRangeL- (halfSlipRange*3),x2=time+86400000,y2=customRangeL- (halfSlipRange*3),xloc=xloc.bar_time,color=color.orange,style=line.style_dashed)
    rr3chRangeShortLabel=label.new (x=bar_index,y=customRangeL- (halfSlipRange*3),color=color.orange,style=label.style_none,size=size.small,textcolor=color.orange,text_font_family=font.family_monospace,text=”(3) “+str.tostring (customRangeL- (halfSlipRange*3),’#.000′)),
    // To the moon 4:1
    //line.new(x1 = time, y1 = low – (halfRange*4), x2 = time + 86400000, y2 = low – (halfRange*4), xloc = xloc.bar_time),
    myLabel=label.new(x=bar_index,y=high,color=color.white,
    style=label.style_label_down,size=size.small,
    text=
    “H: “+str.tostring(high) +
    “\nL: “+str.tostring(low) +
    “\nR: “+str.tostring(candleRange) +
    “\nHR: “+str.tostring(high-halfRange))
    //”\nSS: ” + str.tostring(high + 0.07))
    // Modify the label’s y-axis behaviour; show it below the price bar
    label.set_yloc(id=myLabel,yloc=yloc.abovebar)
    1 user thanked author for this post.
    #242561

    It would be great if you share also screenshots…

    #242562

    Hey Ivan

    Screenshots attached.  The indicator can be set to be long/short or both.  The indicator shows entry, SL (stop loss) and then 1.5RR 2RR and 3RR price targets.

    I set the anchor candle to 9:15am usually to start the trade on 9:30 ES Time.

     

    Hope that helps.

    #242667

    I think this would be very useful indeed, I am currently looking into testing the same signal for the ASX200

    #242670

    Hi!

    Here you have the code:

     

    1 user thanked author for this post.
    #243446

    Hi Ivan and everyone else.

    It’s taken a lot longer than expected to load the indicator but i’ve now done it.  Currently I only see the long side to the indicator and the short side doesn’t load.  I’ll post screenshots to show you what happens in prorealtime and what should happen in if it were in TradingView.

    Is it possible to remove the 1R:1 line and instead add a 4:1 and a 5:1 reward to risk line please?  If 3R, 4R and 5R are all in different colours that would be great.

    I have updated the TradingView pine script code to include 4:1 and 5:1. let me know if you want me to supply the updated pinescript code.

    Thanks,
    Darren

    #243678

    Hi Darren,

    Ivan has given us customisations!

    If you load the indicator on the price chart, you can click on it and use ‘Configure’ with the spanner symbol. Look below Start Date and Slippage. Check the box CFRangeShort and you will have short targets printed same as the long.

    As for the other requests you may have to adapt that in your code provided. You could just copy/paste “tp3=customrange+3*sliprange” and add TP4 etc using the block of code for each drawing description. The colour can be changed there too.

    I’m testing this out and looks like a pretty fun way to deal with opening drives on my market. Beware the double losses though, I will only trade this once a day to minimise whipsaws.

    What market do you trade this on?

    CC

    1 user thanked author for this post.
Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login