buy after 3 events

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

    Hello,

    I’m trying to figure out how to program a code in which the buy order takes place after an event that happens 3 times in the last 10 days.

    The event is X in the following code:

    MyRSI = rsi[9](Close)
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Low[1]
    for I = 3 to 80
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Low[I + 1]
    x= Low1 < Low2 and RSIMin1 > RSIMin2
    endif
    break
    next
    endif

    Thanks in advance,

    Assaf

    #173236 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    MyRSI = rsi[9](Close)
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
    ONCE Count = 0
    if RsiMin then
       RSIMin1 = MyRSI[1]
       Low1 = Low[1]
       for I = 3 to 80
          if RSIMin[I] then
             RSIMin2 = MyRSI[I + 1]
             Low2 = Low[I + 1]
             x= Low1 < Low2 and RSIMin1 > RSIMin2
             Count = Count + 1
          endif
          break
       next
    endif

    check when COUNT  reaches 3 and no more than 10 days have elapsed.

    Actually I am not sure your code is fine. I fear that BREAK may affect Count in a wrong way.

    Try it, but if it doesn’t work, add a better explanation of what it does and what you need.

    assafn and Midlanddave thanked this post
    #173251 quote
    assafnassafn
    Participant
    Average

    Thank you. I think you are right about the BREAK thing, This is the corrected version of it:

    MyRSI = rsi[9](Close)
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
    ONCE Count = 0
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Low[1]
    for I = 3 to 80
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Low[I + 1]
    x= Low1 < Low2 and RSIMin1 > RSIMin2
    Count = Count + 1
    break
    endif
    next
    endif

     

    Can you please show me how to write a buying order that makes sure that all 3 events occur within 10 days?

    Thanks again,

    Assaf

    #173254 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    If summation[8](Count >= 3) Then
    assafn 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

buy after 3 events


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
assafn @assafn Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/06/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...