Strategy based on PRC Supertrend Extended

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #237671 quote
    pdrh
    Participant
    Average

    Hi,

    Has anyone coded a strategy based on the PRC Supertrend Extended and if so can you post it

    Cheers

    #237682 quote
    Iván González
    Moderator
    Legend

    Hi!
    Here you have an example from Nicolas indicator (https://www.prorealcode.com/prorealtime-indicators/supertrend-extended/)

    // --- settings
    multiplier=2.236
    period=66
    type=1 //1 = use ATR , 2 = Use standard deviation , 3 = Use standard error
    midperiod=10
    // --- end of settings
    
    type=max(1,type)
    if type=1 then
    moy=averagetruerange[period](close)
    elsif type=2 then
    moy=std[period](close)
    elsif type=3 then
    moy=ste[period](close)
    endif
    
    myprice=(highest[midperiod](high)+lowest[midperiod](low))/2
    up=myprice+multiplier*moy
    dn=myprice-multiplier*moy
    once trend=1
    if close>up[1] then
    trend=1
    elsif close<dn[1] then
    trend=-1
    endif
    if trend<0 and trend[1]>0 then
    flag=1
    else
    flag=0
    endif
    if trend>0 and trend[1]<0 then
    flagh=1
    else
    flagh=0
    endif
    if trend>0 and dn<dn[1] then
    dn=dn[1]
    endif
    if trend<0 and up>up[1] then
    up=up[1]
    endif
    if flag=1 then
    up=myprice+multiplier*moy
    endif
    if flagh=1 then
    dn=myprice-multiplier*moy
    endif
    if trend=1 then
    mysupertrend=dn
    offset=moy
    //color1=0
    //color2=191
    //color3=255
    else
    mysupertrend=up
    offset=-moy
    //color1=255
    //color2=69
    //color3=0
    endif
    
    if trend=1 and trend[1]<>1 then
    //drawarrowup(barindex,mysupertrend) coloured(color1,color2,color3)
    buy 1 contract at market
    endif
    if trend=-1 and trend[1]<>-1 then
    //drawarrowdown(barindex,mysupertrend) coloured(color1,color2,color3)
    sellshort 1 contract at market
    endif
    pdrh thanked this post
    #237700 quote
    pdrh
    Participant
    Average

    I was hoping for something a little more robust

     

    I have tried a strategy using Supertrend Extended on 2 timeframes to determine the trend and Nicolas’s U BOT Alerts to deternmine the entry

    and this seems to be promising.

    I would post the code but I cannot see the link

    Screenshot-2024-09-17-201651.png Screenshot-2024-09-17-201651.png
    #237710 quote
    GraHal
    Participant
    Master

    You can add the code as an .itf file using ‘select file’ same as adding a screenshot.

    #238825 quote
    SnorreDK
    Participant
    Junior

    How have your strategies been performing out-of-sample (OOS) lately?

    Would you mind sharing the code or the ITF file?

    #238840 quote
    pdrh
    Participant
    Average

    The last few weeks have not been as good . I have modified the code for which I  posted the the detailed report butIneed to find a way to improve the results when the price is trading sideways on the 30 sec timeframe .

    Any suggestions would be appreciated

    Screenshot-2024-10-11-164539.png Screenshot-2024-10-11-164539.png
    #238842 quote
    SnorreDK
    Participant
    Junior

    Noone can help u if u not share the code

    #238843 quote
    pdrh
    Participant
    Average

    I have exported the itf file and selected it but for some reason it is not appearing

    Screenshot-2024-10-11-170124.png Screenshot-2024-10-11-170124.png
    #238848 quote
    GraHal
    Participant
    Master

    After getting to the stage shown in your screenshot, i.e. .itf already attached … all you should need to do is to click on ‘Submit’ at bottom of page.

    Weird that the .itf is not posting … try again.

    #238849 quote
    pdrh
    Participant
    Average

    That is what I have done a number of times . I have selected both the itf file and screenshot but only the screenshot is uploading

    #238850 quote
    SnorreDK
    Participant
    Junior

    why not just paste the code?

    #238856 quote
    GraHal
    Participant
    Master

    Did you export the .itf using Option 1 – ‘None, Code will be fully editable’ ?

    Above is just a thought as to why the .itf may not be attaching??

    #238857 quote
    pdrh
    Participant
    Average

    Yes I exported with “none’

    I am going to try rebooting my computer

    #238858 quote
    pdrh
    Participant
    Average

    Because then the code is not as easily read

    // Definition of code parameters
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 100000
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 155800

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 100000
    timeEnterBefore = time >= noEntryBeforeTime

    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 150000
    timeEnterAfter = time < noEntryAfterTime

    p=1
    Start=100000
    If Time=start then
    LTC=0
    STC=0
    SRev=0
    LRev=0
    endif
    Timeframe (10minutes,updateonclose)
    ignored, indicator1 = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    indicator2, ignored = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    iprice10=totalprice
    TRND=ROC[2](iprice10)
    UP10 = ((indicator1>indicator2)and TRND>0)
    DWN10 =((indicator1<indicator2)and TRND<0)

    Timeframe(default)
    ignored, indicator3 = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    indicator4, ignored = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    UP = (indicator3 >= indicator4)
    DWN =(indicator3 <= indicator4)
    iprice=totalprice
    Ind5=Supertrend[a,b]
    UE=iprice crosses over Ind5
    DE =iprice crosses under Ind5
    If UP and UP10 and UE and LTC<1 and SRev<1and Timeenterbefore and Timeenterafter AND not onmarket then
    Buy p contract at market
    LTC=LTC+1
    SL=Lstp
    TP=Ltgt
    Endif
    //if long stopped and short term trend down enter short
    IF longonmarket[1] and not onmarket and strategyprofit<strategyprofit[1] and DWN and LRev<1 then
    sellshort p contracts at market
    LRev=LRev+1
    Srev=Srev+1
    SL=sstpR
    TP=stgtR
    Endif
    If DWN and DWN10 and DE and STC<1 and LRev<1and Timeenterbefore and Timeenterafter and NOT onmarket then
    Sellshort p contract at market
    STC=STC+1
    SL=sstp
    TP=stgt
    Endif
    //if short stopped and short term tren up then
    If shortonmarket[1] and not onmarket and strategyprofit<strategyprofit[1] and UP and SRev<1 then
    buy p contracts at market
    SRev=SRev+1
    Lrev=Lrev+1
    SL=lstpR
    TP=ltgtR
    Endif
    set Stop PLoss SL
    Set target pprofit TP

    #238859 quote
    SnorreDK
    Participant
    Junior

    Code

    // Definition of code parameters
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 100000
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 155800
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 100000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 150000
    timeEnterAfter = time < noEntryAfterTime
    
    p=1
    Start=100000
    If Time=start then
    LTC=0
    STC=0
    SRev=0
    LRev=0
    endif
    Timeframe (10minutes,updateonclose)
    ignored, indicator1 = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    indicator2, ignored = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    iprice10=totalprice
    TRND=ROC[2](iprice10)
    UP10 = ((indicator1>indicator2)and TRND>0)
    DWN10 =((indicator1<indicator2)and TRND<0)
    
    Timeframe(default)
    ignored, indicator3 = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    indicator4, ignored = CALL “PRC_SuperTrend Extended”[2.236, 66, 1, 10]
    UP = (indicator3 >= indicator4)
    DWN =(indicator3 <= indicator4)
    iprice=totalprice
    Ind5=Supertrend[a,b]
    UE=iprice crosses over Ind5
    DE =iprice crosses under Ind5
    If UP and UP10 and UE and LTC<1 and SRev<1and Timeenterbefore and Timeenterafter AND not onmarket then
    Buy p contract at market
    LTC=LTC+1
    SL=Lstp
    TP=Ltgt
    Endif
    //if long stopped and short term trend down enter short
    IF longonmarket[1] and not onmarket and strategyprofit<strategyprofit[1] and DWN and LRev<1 then
    sellshort p contracts at market
    LRev=LRev+1
    Srev=Srev+1
    SL=sstpR
    TP=stgtR
    Endif
    If DWN and DWN10 and DE and STC<1 and LRev<1and Timeenterbefore and Timeenterafter and NOT onmarket then
    Sellshort p contract at market
    STC=STC+1
    SL=sstp
    TP=stgt
    Endif
    //if short stopped and short term tren up then
    If shortonmarket[1] and not onmarket and strategyprofit<strategyprofit[1] and UP and SRev<1 then
    buy p contracts at market
    SRev=SRev+1
    Lrev=Lrev+1
    SL=lstpR
    TP=ltgtR
    Endif
    set Stop PLoss SL
    Set target pprofit TP
Viewing 15 posts - 1 through 15 (of 15 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

Strategy based on PRC Supertrend Extended


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
pdrh @pdrh Participant
Summary

This topic contains 14 replies,
has 4 voices, and was last updated by SnorreDK
1 year, 11 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 09/17/2024
Status: Active
Attachments: 3 files
Logo Logo
Loading...