Help with creating condition after an event

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #83355 quote
    Ritesh Nayak
    Participant
    Junior

    Hi Everyone,

     

    can some one please help me with the below?

    So i have 3 conditions coded. Lets say c1, c2, c3

    What i want to code

    1. check if c1 and c2 happen on a candle. for example, if c1 and c2 then…
    2. if step one is confirmed then for the next 20 candles look for c3.
    3. when step 2 happens, go long on the next bar

    for example, on current bar (lets call it )bar[0], c1 and c2 are met and then on 5th bar after bar[0] if c3 happens then open of 6th bar strategy should go long

    Would someone please help

    #83356 quote
    robertogozzi
    Moderator
    Master

    When C1 snd C2 are met, the following 20 bars shall they still be true to allow C3 to be also true?

    What should happen if, after 20 bars, C3 has never been true, but C1 and C3 still are? Shall another 20 bars be tallied?

    #83357 quote
    Ritesh Nayak
    Participant
    Junior

    Unfoortunately, c1 and c2 show up on bar[0] and not continue till bar 20.

    and if c3 is not happened till 20 bars then all goes back to zero

     

    if that makes sense

    #83358 quote
    robertogozzi
    Moderator
    Master

    Try this (not tested):

    ONCE BarCount = o
    IF BarCount = 20 THEN
       BarCount = 0
    ENDIF
    IF c1 AND c2 AND BarCount = 0 THEN
       BarCount = 1
    ELSIF BarCount THEN
       BarCount = BarCount + 1
    ENDIF
    IF c3 AND BarCount <> 0 THEN
       BUY.....
       BarCount = 0
    ENDIF

     

    Ritesh Nayak and Nicolas thanked this post
    #83359 quote
    Ritesh Nayak
    Participant
    Junior

    that worked. thanks. really appreciate it

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Help with creating condition after an event


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Ritesh Nayak
7 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/22/2018
Status: Active
Attachments: No files
Logo Logo
Loading...