How do I stop repeat signals

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #39423 quote
    paulonpaulon
    Participant
    Average

    I am creating some indicators based on various combinations including moving average crossovers.   Once I have an UP signal, how can I code the indicator to ignore more UP signals until there has been a DOWN signal?

    #39436 quote
    NicolasNicolas
    Keymaster
    Legend

    Make a variable that store the last signal direction and test it before launching a new signal.

    #39466 quote
    paulonpaulon
    Participant
    Average

    Nicolas thanks for your reply but I’m sorry I don’t understand how to do this.

    #39517 quote
    NicolasNicolas
    Keymaster
    Legend

    I could show you directly into your code if you can share it with us.

    #50953 quote
    margincallcatmargincallcat
    Participant
    Average

    I bump this thread since i want the same thing. For this current easy command i dont want it to give repeated signals when Lower Low and Lower Close repeats.

    //defparam CALCULATEONLASTBARS=20
    
    if on=1 then
    
    stoch=Stochastic[12,3](close)
    ema=average[10,1](close)
    
    //
    ll=low[1]<low[2]
    lc=close[1]<close[2]
    
    
    
    if ll and lc and stoch[2]>80 and close[2]>ema then
    drawtext("LL LC",barindex[1],high[1]+range[1],SansSerif,standard,12)coloured(255,50,50)
    drawarrowdown(barindex[1],high[1])
    endif
    
    //hh=high[1]>high[2]
    //hc=close[1]>close[2]
    //hc2=high>high[1]
    //
    //if hh and hc and hc2 then
    //drawtext("HH HC",barindex[1],low[1]-range[1],SansSerif,standard,12)coloured(50,255,50)
    //drawarrowup(barindex[1],low[1])
    //endif
    endif
    return
    

    Thankful for help!

     

    //Viktor

    EURUSD-2-hours.png EURUSD-2-hours.png
    #50955 quote
    margincallcatmargincallcat
    Participant
    Average

    I tried this

     

    //defparam CALCULATEONLASTBARS=20
    
    if on=1 then
    
    stoch=Stochastic[12,3](close)
    ema=average[10,1](close)
    
    //
    ll=low[1]<low[2]
    lc=close[1]<close[2]
    
    
    
    if signal=0 and ll and lc and stoch[2]>80 and close[2]>ema then
    drawtext("LL LC",barindex[1],high[1]+range[1],SansSerif,standard,12)coloured(255,50,50)
    drawarrowdown(barindex[1],high[1])
    signal=1
    else 
    signal=0
    endif
    
    //hh=high[1]>high[2]
    //hc=close[1]>close[2]
    //hc2=high>high[1]
    //
    //if hh and hc and hc2 then
    //drawtext("HH HC",barindex[1],low[1]-range[1],SansSerif,standard,12)coloured(50,255,50)
    //drawarrowup(barindex[1],low[1])
    //endif
    endif
    return
    

    and it gets rid of one repetition. How do i keep it/determine length?

    #50956 quote
    margincallcatmargincallcat
    Participant
    Average

    i did this now and it works OK but if anyone has a better suggestion i all ears 🙂

    //defparam CALCULATEONLASTBARS=20
    
    if on=1 then
    
    stoch=Stochastic[12,3](close)
    ema=average[10,1](close)
    atr=AverageTrueRange[10](close)
    //
    ll=low[1]<low[2]
    lc=close[1]<close[2]
    
    
    
    if signal=0 and signal[1]=0 and signal[2]=0 and signal[3]=0 and ll and lc and stoch[2]>80 and close[2]>ema then
    drawtext("LL LC",barindex[1],high[1]+atr,SansSerif,standard,12)coloured(255,50,50)
    drawarrowdown(barindex[1],high[1])
    signal=1
    else 
    signal=0
    endif
    
    //hh=high[1]>high[2]
    //hc=close[1]>close[2]
    //hc2=high>high[1]
    //
    //if hh and hc and hc2 then
    //drawtext("HH HC",barindex[1],low[1]-range[1],SansSerif,standard,12)coloured(50,255,50)
    //drawarrowup(barindex[1],low[1])
    //endif
    endif
    return
    
    #51046 quote
    NicolasNicolas
    Keymaster
    Legend

    You could have saved the barindex of the first signal and then test if enough bars have passed since then to give a new signal.

    Or store the first signal price into a variable and test if the new signal is different from the last saved one.

    #51050 quote
    margincallcatmargincallcat
    Participant
    Average

    You mentioned that in your first reply above, but i dont know how to do that. Can you please provide a code example?

    Thanks

    #51269 quote
    margincallcatmargincallcat
    Participant
    Average

    ???

    #51280 quote
    NicolasNicolas
    Keymaster
    Legend

    Sorry @lebrinque, but sometimes between 2 topics, I take some rest 🙂 It was days off yesterday in France also!

    This is the amended code:

    stoch=Stochastic[12,3](close)
    ema=average[10,1](close)
    atr=AverageTrueRange[10](close)
    //
    ll=low[1]<low[2]
    lc=close[1]<close[2]
     
     if ll and lc and stoch[2]>80 and close[2]>ema and barindex-lastsignal>2 then
    drawtext("LL LC",barindex[1],high[1]+atr,SansSerif,standard,12)coloured(255,50,50)
    drawarrowdown(barindex[1],high[1])
    lastsignal=barindex[1]
    endif
    
    return

    ‘lastsignal’ variable is your new friend, take care of him 🙂

    margincallcat thanked this post
    non-repeating-trading-signals.png non-repeating-trading-signals.png
    #51282 quote
    margincallcatmargincallcat
    Participant
    Average

    Thank you!!

    #51296 quote
    margincallcatmargincallcat
    Participant
    Average

    Also @nicolas the other topic i created “Command depending on prior command” as a spinoff from this one – hope it was OK to create a new thread for that.

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

How do I stop repeat signals


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
paulon @paulon Participant
Summary

This topic contains 12 replies,
has 3 voices, and was last updated by margincallcatmargincallcat
8 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/29/2017
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...