A coding question

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #197072 quote
    MarcoMarco
    Participant
    New
    Hi, it would be nice if someone can answer this…. Are this 2 code are the same and work the same way? CLOSE < low[1] or CLOSE < low[2] or CLOSE < low[3] or CLOSE < low[4] ——————————————– CLOSE < (low[1] or low[2] or low[3] or low[4]) Many thanks
    #197073 quote
    MarcoMarco
    Participant
    New
    Hi, it would be nice if someone can answer this…. Are this 3 code are the same and work the same way? CLOSE < low[1] or CLOSE < low[2] or CLOSE < low[3] or CLOSE < low[4] ——————————————– CLOSE < (low[1] or low[2] or low[3] or low[4]) ————————————————- c1 = CLOSE < low[1] c2 = CLOSE < low[2] c3 = CLOSE < low[3] c4 = CLOSE < low[4] s1 = c1 or C2 or C3 or c4 Many thanks
    #197074 quote
    GraHalGraHal
    Participant
    Master
    If you number your options then it’s easier fior us to help you as we can easily refer to numbers. 🙂 This S1 = CLOSE < low[1] or CLOSE < low[2] or CLOSE < low[3] or CLOSE < low[4] is same as c1 = CLOSE < low[1] c2 = CLOSE < low[2] c3 = CLOSE < low[3] c4 = CLOSE < low[4] s1 = c1 or C2 or C3 or c4   This one CLOSE < (low[1] or low[2] or low[3] or low[4]) won’t work for what you want it to do, e.g. or  low[2]  will only give you the value of low 2 bars ago.
    Midlanddave thanked this post
    #197075 quote
    JSJS
    Participant
    Master
    Code1 = Close<Low[1] or Close<Low[2] or Close<Low[3] or Close<Low[4]
    Code2 = Close<Low[1] or Low[2] or Low[3] or Low[4]
    
    c1 = Close<Low[1]
    c2 = Close<Low[2]
    c3 = Close<Low[3]
    c4 = Close<Low[4]
    
    Code3 = c1 or c2 or c3 or c4
    
    Return Code1 as "Code1", Code2 as "Code2", Code3 as "Code3"
    

    In addition to GraHal’s explanation:

    You can set up a simple indicator to test…

    Then you see that Code1 and Code3 give the same results (0 or 1) but that Code2 is always true (always 1). This is probably because in Code2 you don’t give a condition to Low[2], Low[3] and Low[4]. So you’re basically saying here, is there a Low[2] or a Low[3] or a Low[4] (and there always are).

    GraHal and Midlanddave thanked this post
    #197077 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    As to your first post:
    • the first line is correct, it’ll be true whenever CLOSE < anyone of the previous 4 LOWs
    • the second line is logically incorrect, as it will ALWAYS be true, as you do not compare CLOSE to those LOWS; you compare CLOSE to the fact that anyone of those LOWs is <> 0, which cannot be false.
    #197082 quote
    MarcoMarco
    Participant
    New
    thank you guys, got it now, very appreciate 🙂
Viewing 6 posts - 1 through 6 (of 6 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

A coding question


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marco @wingyip Participant
Summary

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

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