programming multiple signals in multiple bars

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #166495 quote
    JaldideeJaldidee
    Participant
    Average

    Hello,

    I was wondering if someone could help me.

    What I want to achieve is a program that looks for two signals over multiple bars.

    Yhe idea is that when the ATR on the dow 5 minutechart crosses over the value of 25 and a few bars (not more then 7) later the price crosses under the EMA10 a buy setup is triggered.

    If you look at the picture below you see that the trade is triggered also to early.

    Hope someone can help me.

    Many thanks in advance.

    Kind Regards,

    Jaldidee

    picture-ema-cross.png picture-ema-cross.png
    #166512 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    DEFPARAM CumulateOrders = FALSE
    ONCE MaxBars = 7                       //Keep signal alive for a max 7 bars
    ONCE Count   = 0
    MyATR        = AverageTrueRange[14](close)
    Sma10        = Average[10,0](close)
    c1           = MyATR CROSSES OVER 25
    c2           = close CROSSES UNDER Sma10
    IF c1 = 1 THEN
       Count = 1
    ELSE
       IF c1[1] = 1 THEN
          c1 = c1[1]
          Count = Count + 1
          IF Count > MaxBars THEN
             Count = 0
             c1    = 0
          ENDIF
       ENDIF
    ENDIF
    IF Not OnMarket AND c1 AND c2 THEN
       BUY 1 Contract AT Market
       c1    = 0
       Count = 0
    SET TARGET pPROFIT 100
    SET STOP   pLOSS   50
    ENDIF
    //graph count
    //graph c1
    //graph c2
    #166539 quote
    JaldideeJaldidee
    Participant
    Average

    Hello Roberto,

     

    Thank you very much. It works perfectly…

    However I have a followup question. Next step is to set an entry, exit and target when both conditions are met.

    How would you program that? Because I tried it with the indicator, highest[10] .

    I set the entry at highest[10] and i want to ext at higest[10] minus 1* ATR and want to take profit at 2 * ATR.

    This works for the entry, but not to set a exit and target, because the program keeps recalculating the value of higest[10] and thus contnually changing the exit and target.

    Kind regards,

    Jaldidee

    #166560 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    DEFPARAM CumulateOrders = FALSE
    ONCE MaxBars = 7                       //Keep signal alive for a max 7 bars
    ONCE Count   = 0
    MyATR        = AverageTrueRange[14](close)
    Sma10        = Average[10,0](close)
    c1           = MyATR CROSSES OVER 25
    c2           = close CROSSES UNDER Sma10
    IF c1 = 1 THEN
       Count = 1
    ELSE
       IF c1[1] = 1 THEN
          c1 = c1[1]
          Count = Count + 1
          IF Count > MaxBars THEN
             Count = 0
             c1    = 0
          ENDIF
       ENDIF
    ENDIF
    IF c1 AND c2 THEN
       Entry = highest[10](high)
       SL    = Entry - MyATR
       TP    = Entry + (MyATR * 2)
    ENDIF
    IF Not OnMarket AND c1 AND c2 THEN
       BUY 1 Contract AT Entry STOP
       SET TARGET PROFIT TP
       SET STOP   LOSS   SL
       c1    = 0
       Count = 0
    ENDIF
    thanked this post
Viewing 4 posts - 1 through 4 (of 4 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

programming multiple signals in multiple bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Jaldidee @jaldidee Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/08/2021
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...