PRC QMP Filter to provide trading signals

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #192589 quote
    robertogozzi
    Moderator
    Master

    There you go:

    //PRC_QMP Filter | indicator
    //29.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    DEFPARAM DrawOnLastBarOnly = true
    //--- parameters
    short = 12
    long = 26
    signal = 9
    RSIPeriod = 8
    SF = 1
    QQE = 3
    //---
    
    // --- MACD ZeroLag
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
    
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
    
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
    
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
    
    SignalMACD=signal1+DIFFERENCE2
    
    // --- QQE
    WildersPeriod = RSIPeriod * 2 - 1
    if barindex>WildersPeriod then
    
    MyRsi = rsi[RSIPeriod](close)
    RsiMa = exponentialaverage[SF](MyRsi)
    AtrRsi = abs(RsiMa[1] - RsiMa)
    MaAtrRsi = exponentialaverage[WildersPeriod](AtrRsi)
    dar = exponentialaverage[WildersPeriod](MaAtrRsi) * QQE
    
    trr=TrLevelSlow[1]
    dv = trr
    if RsiMA[0]<trr then
    trr = RsiMA[0] + dar
    if(RsiMA[1]<dv) then
    if(trr>dv) then
    trr=dv
    endif
    endif
    elsif RsiMA[0]>trr then
    trr = RsiMA[0] - dar
    if(RsiMA[1]>dv) then
    if(trr<dv) then
    trr=dv
    endif
    endif
    
    endif
    TrLevelSlow=trr
    endif
    
    // --- signals
    atr=averagetruerange[100]
    if zerolagMACD>=signalMACD and RsiMA>=trr and lasttrend<>1 then
    lasttrend=1
    r1=0
    g1=255
    b1=0
    lowbar = barindex
    lowprice = low-atr/2
    ilow = low-atr/2
    elsif zerolagMACD<signalMACD and RsiMA<trr and lasttrend<>-1 then
    lasttrend=-1
    r0=255
    g0=0
    b0=0
    highbar = barindex
    highprice = high+atr/2
    ihigh = high+atr/2
    endif
    
    drawtext("●",lowbar,lowprice,Dialog,Bold,12) coloured(r1,g1,b1)
    drawtext("●",highbar,highprice,Dialog,Bold,12) coloured(r0,g0,b0)
    
    return ilow,ihigh
    #192590 quote
    s00071609
    Participant
    Senior

    Perfect thank you very much

    #193477 quote
    s00071609
    Participant
    Senior

    This works perfectly fine. However would it be possible to show last 3 signals instead of only 1. This is because I am realising it might be helpful to see how the signal played out most recently.

     

    thanks

    #193502 quote
    robertogozzi
    Moderator
    Master

    I will do asap.

    Razz thanked this post
    #193880 quote
    s00071609
    Participant
    Senior

    Any progress with this.?

     

    thanks

    #193890 quote
    robertogozzi
    Moderator
    Master

    Sorry, I’ve been quite busy lately.

    There you go (this will plot the last 3 signals in total):

    //PRC_QMP Filter | indicator
    //29.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    DEFPARAM DrawOnLastBarOnly = true
    //
    ONCE MaxSignals = 3
    IF BarIndex = 0 THEN
    FOR i = 1 TO MaxSignals
    $Signal[i] = 0
    $myBar[i]  = 0
    $Price[i]  = 0
    NEXT
    ENDIF
    //
    //--- parameters
    short = 12
    long = 26
    signal = 9
    RSIPeriod = 8
    SF = 1
    QQE = 3
    //---
     
    // --- MACD ZeroLag
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
     
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
     
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
     
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
     
    SignalMACD=signal1+DIFFERENCE2
     
    // --- QQE
    WildersPeriod = RSIPeriod * 2 - 1
    if barindex>WildersPeriod then
     
    MyRsi = rsi[RSIPeriod](close)
    RsiMa = exponentialaverage[SF](MyRsi)
    AtrRsi = abs(RsiMa[1] - RsiMa)
    MaAtrRsi = exponentialaverage[WildersPeriod](AtrRsi)
    dar = exponentialaverage[WildersPeriod](MaAtrRsi) * QQE
     
    trr=TrLevelSlow[1]
    dv = trr
    if RsiMA[0]<trr then
    trr = RsiMA[0] + dar
    if(RsiMA[1]<dv) then
    if(trr>dv) then
    trr=dv
    endif
    endif
    elsif RsiMA[0]>trr then
    trr = RsiMA[0] - dar
    if(RsiMA[1]>dv) then
    if(trr<dv) then
    trr=dv
    endif
    endif
     
    endif
    TrLevelSlow=trr
    endif
     
    // --- signals
    atr=averagetruerange[100]
    if zerolagMACD>=signalMACD and RsiMA>=trr and lasttrend<>1 then
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Signal[i] = $Signal[j]
    $myBar[i]  = $myBar[j]
    $Price[i]  = $Price[j]
    NEXT
    lasttrend=1
    r1=0
    g1=255
    b1=0
    lowbar = barindex
    lowprice = low-atr/2
    ilow = low-atr/2
    $Signal[1] = -1
    $myBar[1]  = lowbar
    $Price[1]  = lowprice
    elsif zerolagMACD<signalMACD and RsiMA<trr and lasttrend<>-1 then
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Signal[i] = $Signal[j]
    $myBar[i]  = $myBar[j]
    $Price[i]  = $Price[j]
    NEXT
    lasttrend=-1
    r0=255
    g0=0
    b0=0
    highbar = barindex
    highprice = high+atr/2
    ihigh = high+atr/2
    $Signal[1] = 1
    $myBar[1]  = highbar
    $Price[1]  = highprice
    endif
    
    FOR i = 1 TO MaxSignals
    x = $myBar[i]
    y = $Price[i]
    IF $Signal[i] = - 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r1,g1,b1)
    ELSIF $Signal[i] = 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r0,g0,b0)
    ENDIF
    NEXT
     
    return ilow,ihigh

    There you go (this will plot the last 6 signal, 3 each type)):

    //PRC_QMP Filter | indicator
    //29.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    DEFPARAM DrawOnLastBarOnly = true
    //
    ONCE MaxSignals = 3
    IF BarIndex = 0 THEN
    FOR i = 1 TO MaxSignals
    $Lsignal[i] = 0
    $LmyBar[i]  = 0
    $Lprice[i]  = 0
    //
    $Ssignal[i] = 0
    $SmyBar[i]  = 0
    $Sprice[i]  = 0
    NEXT
    ENDIF
    //
    //--- parameters
    short = 12
    long = 26
    signal = 9
    RSIPeriod = 8
    SF = 1
    QQE = 3
    //---
     
    // --- MACD ZeroLag
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
     
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
     
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
     
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
     
    SignalMACD=signal1+DIFFERENCE2
     
    // --- QQE
    WildersPeriod = RSIPeriod * 2 - 1
    if barindex>WildersPeriod then
     
    MyRsi = rsi[RSIPeriod](close)
    RsiMa = exponentialaverage[SF](MyRsi)
    AtrRsi = abs(RsiMa[1] - RsiMa)
    MaAtrRsi = exponentialaverage[WildersPeriod](AtrRsi)
    dar = exponentialaverage[WildersPeriod](MaAtrRsi) * QQE
     
    trr=TrLevelSlow[1]
    dv = trr
    if RsiMA[0]<trr then
    trr = RsiMA[0] + dar
    if(RsiMA[1]<dv) then
    if(trr>dv) then
    trr=dv
    endif
    endif
    elsif RsiMA[0]>trr then
    trr = RsiMA[0] - dar
    if(RsiMA[1]>dv) then
    if(trr<dv) then
    trr=dv
    endif
    endif
     
    endif
    TrLevelSlow=trr
    endif
     
    // --- signals
    atr=averagetruerange[100]
    if zerolagMACD>=signalMACD and RsiMA>=trr and lasttrend<>1 then
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Ssignal[i] = $Ssignal[j]
    $SmyBar[i]  = $SmyBar[j]
    $Sprice[i]  = $Sprice[j]
    NEXT
    lasttrend=1
    r1=0
    g1=255
    b1=0
    lowbar = barindex
    lowprice = low-atr/2
    ilow = low-atr/2
    $Ssignal[1] = -1
    $SmyBar[1]  = lowbar
    $Sprice[1]  = lowprice
    elsif zerolagMACD<signalMACD and RsiMA<trr and lasttrend<>-1 then
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Lsignal[i] = $Lsignal[j]
    $LmyBar[i]  = $LmyBar[j]
    $Lprice[i]  = $Lprice[j]
    NEXT
    lasttrend=-1
    r0=255
    g0=0
    b0=0
    highbar = barindex
    highprice = high+atr/2
    ihigh = high+atr/2
    $Lsignal[1] = 1
    $LmyBar[1]  = highbar
    $Lprice[1]  = highprice
    endif
    
    FOR i = 1 TO MaxSignals
    x = $SmyBar[i]
    y = $Sprice[i]
    IF $Ssignal[i] = - 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r1,g1,b1)
    ENDIF
    //
    x = $LmyBar[i]
    y = $Lprice[i]
    IF $Lsignal[i] = 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r0,g0,b0)
    ENDIF
    NEXT
     
    return ilow,ihigh

    You can increase or decrease MaxSignals to best suit your needs.

    Razz thanked this post
    #194016 quote
    s00071609
    Participant
    Senior

    Thank you. It shows the dots specified 3 or 6 when the indicator is loaded. But as the price moves it shows only the last 2 dots rather than all 6 or 3.

    #194030 quote
    robertogozzi
    Moderator
    Master

    Market are currently closed, so I cannot test it, but I think it’s due the continuous live refresh of the chart.

    I’ll check on Monday and I will post the updated code.

    #194174 quote
    robertogozzi
    Moderator
    Master

    This updated version is working finely:

    //PRC_QMP Filter | indicator
    //29.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    DEFPARAM DrawOnLastBarOnly = true
    //
    ONCE MaxSignals = 3
    IF BarIndex = 0 THEN
    FOR i = 1 TO MaxSignals
    $Signal[i] = 0
    $myBar[i]  = 0
    $Price[i]  = 0
    NEXT
    ENDIF
    //
    //--- parameters
    short = 12
    long = 26
    signal = 9
    RSIPeriod = 8
    SF = 1
    QQE = 3
    //---
     
    // --- MACD ZeroLag
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
     
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
     
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
     
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
     
    SignalMACD=signal1+DIFFERENCE2
     
    // --- QQE
    WildersPeriod = RSIPeriod * 2 - 1
    if barindex>WildersPeriod then
     
    MyRsi = rsi[RSIPeriod](close)
    RsiMa = exponentialaverage[SF](MyRsi)
    AtrRsi = abs(RsiMa[1] - RsiMa)
    MaAtrRsi = exponentialaverage[WildersPeriod](AtrRsi)
    dar = exponentialaverage[WildersPeriod](MaAtrRsi) * QQE
     
    trr=TrLevelSlow[1]
    dv = trr
    if RsiMA[0]<trr then
    trr = RsiMA[0] + dar
    if(RsiMA[1]<dv) then
    if(trr>dv) then
    trr=dv
    endif
    endif
    elsif RsiMA[0]>trr then
    trr = RsiMA[0] - dar
    if(RsiMA[1]>dv) then
    if(trr<dv) then
    trr=dv
    endif
    endif
     
    endif
    TrLevelSlow=trr
    endif
     
    // --- signals
    atr=averagetruerange[100]
    IF OpenTime <> OpenTime[1] THEN
    if zerolagMACD>=signalMACD and RsiMA>=trr and lasttrend<>1 then
    lasttrend=1
    r1=0
    g1=255
    b1=0
    lowbar = barindex
    lowprice = low-atr/2
    ilow = low-atr/2
    IF $myBar[1] <> barindex THEN
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Signal[i] = $Signal[j]
    $myBar[i]  = $myBar[j]
    $Price[i]  = $Price[j]
    NEXT
    $myBar[1]  = lowbar
    $Price[1]  = lowprice
    $Signal[1] = -1
    endif
    elsif zerolagMACD<signalMACD and RsiMA<trr and lasttrend<>-1 then
    lasttrend=-1
    r0=255
    g0=0
    b0=0
    highbar = barindex
    highprice = high+atr/2
    ihigh = high+atr/2
    IF $myBar[1] <> barindex THEN
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Signal[i] = $Signal[j]
    $myBar[i]  = $myBar[j]
    $Price[i]  = $Price[j]
    NEXT
    $Signal[1] = 1
    $myBar[1]  = highbar
    $Price[1]  = highprice
    endif
    endif
    ENDIF
    
    FOR i = 1 TO MaxSignals
    x = $myBar[i]
    y = $Price[i]
    IF $Signal[i] = - 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r1,g1,b1)
    ELSIF $Signal[i] = 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r0,g0,b0)
    ENDIF
    NEXT
     
    return ilow,ihigh
    //PRC_QMP Filter | indicator
    //29.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    DEFPARAM DrawOnLastBarOnly = true
    //
    ONCE MaxSignals = 3
    IF BarIndex = 0 THEN
    FOR i = 1 TO MaxSignals
    $Lsignal[i] = 0
    $LmyBar[i]  = 0
    $Lprice[i]  = 0
    //
    $Ssignal[i] = 0
    $SmyBar[i]  = 0
    $Sprice[i]  = 0
    NEXT
    ENDIF
    //
    //--- parameters
    short = 12
    long = 26
    signal = 9
    RSIPeriod = 8
    SF = 1
    QQE = 3
    //---
     
    // --- MACD ZeroLag
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
     
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
     
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
     
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
     
    SignalMACD=signal1+DIFFERENCE2
     
    // --- QQE
    WildersPeriod = RSIPeriod * 2 - 1
    if barindex>WildersPeriod then
     
    MyRsi = rsi[RSIPeriod](close)
    RsiMa = exponentialaverage[SF](MyRsi)
    AtrRsi = abs(RsiMa[1] - RsiMa)
    MaAtrRsi = exponentialaverage[WildersPeriod](AtrRsi)
    dar = exponentialaverage[WildersPeriod](MaAtrRsi) * QQE
     
    trr=TrLevelSlow[1]
    dv = trr
    if RsiMA[0]<trr then
    trr = RsiMA[0] + dar
    if(RsiMA[1]<dv) then
    if(trr>dv) then
    trr=dv
    endif
    endif
    elsif RsiMA[0]>trr then
    trr = RsiMA[0] - dar
    if(RsiMA[1]>dv) then
    if(trr<dv) then
    trr=dv
    endif
    endif
     
    endif
    TrLevelSlow=trr
    endif
     
    // --- signals
    atr=averagetruerange[100]
    if zerolagMACD>=signalMACD and RsiMA>=trr and lasttrend<>1 then
    lasttrend=1
    r1=0
    g1=255
    b1=0
    lowbar = barindex
    lowprice = low-atr/2
    ilow = low-atr/2
    IF $SmyBar[1] <> lowbar THEN
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Ssignal[i] = $Ssignal[j]
    $SmyBar[i]  = $SmyBar[j]
    $Sprice[i]  = $Sprice[j]
    NEXT
    ENDIF
    $Ssignal[1] = -1
    $SmyBar[1]  = lowbar
    $Sprice[1]  = lowprice
    elsif zerolagMACD<signalMACD and RsiMA<trr and lasttrend<>-1 then
    lasttrend=-1
    r0=255
    g0=0
    b0=0
    highbar = barindex
    highprice = high+atr/2
    ihigh = high+atr/2
    IF $LmyBar[1] <> highbar THEN
    FOR i = MaxSignals DOWNTO 2
    j = i - 1
    $Lsignal[i] = $Lsignal[j]
    $LmyBar[i]  = $LmyBar[j]
    $Lprice[i]  = $Lprice[j]
    NEXT
    endif
    $Lsignal[1] = 1
    $LmyBar[1]  = highbar
    $Lprice[1]  = highprice
    endif
     
    FOR i = 1 TO MaxSignals
    x = $SmyBar[i]
    y = $Sprice[i]
    IF $Ssignal[i] = - 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r1,g1,b1)
    ENDIF
    //
    x = $LmyBar[i]
    y = $Lprice[i]
    IF $Lsignal[i] = 1 THEN
    drawtext("●",x,y,Dialog,Bold,12) coloured(r0,g0,b0)
    ENDIF
    NEXT
     
    return ilow,ihigh
    Razz thanked this post
    #194375 quote
    s00071609
    Participant
    Senior

    thanks it seems to have solved the issue mentioned earlier. But, it creating multiple dots at the same place which it should not, sometimes a cluster of 3 red or greed dots appear at same place.

    Capture.png Capture.png
    #194384 quote
    robertogozzi
    Moderator
    Master

    Enlarge your chart, they shouldn’t be on the same place.

    #194907 quote
    s00071609
    Participant
    Senior

    There shouldn’t be 3 red or blue dots in a row. It should be a red followed by green and vice versa. But its giving multiple consecutive dots of same colour.

    Capture2.png Capture2.png
    #194913 quote
    robertogozzi
    Moderator
    Master

    It’s can be more than one identical dot.

    Check the original one if it has those dots plotted the same way.

    Of course we can make it work as you want. If you don’t like consecutive identical signals, I can make it.

    Midlanddave thanked this post
Viewing 13 posts - 16 through 28 (of 28 total)
  • You must be logged in to reply to this topic.

PRC QMP Filter to provide trading signals


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Dymjohn @dymjohn Participant
Summary

This topic contains 27 replies,
has 4 voices, and was last updated by robertogozzi
3 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/25/2018
Status: Active
Attachments: 8 files
Logo Logo
Loading...