abnormal behavior of if… and ..and ..and condition

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #92284 quote
    waid
    Participant
    Junior

    Let’s say

    buyCondition = average[10] crosses over average[30]
    if A and B and C and buyCondition then
        ...
    endif

    the result will be totally different from:

    if buyCondition and A and B and C then
        ...
    endif
    

    I found this abnormal behavior when I do my experiment on Nicolas’s nice post (This abnormal behavior is nothing to do with the code of Nicolas’s post. I show the post here is just to give a code base for a quick experiment):

    https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1

    First, you can change the code block (at # line: 22):

    elsif  not realtrading and ordercount>equityCurvePeriod then //fake trading
    if not longontrading and buysignal then

    into:

    elsif  buysignal and not realtrading and ordercount>equityCurvePeriod then //fake trading
        if not longontrading  then

    or

    elsif  buysignal and not realtrading  then //fake trading
        if ordercount>equityCurvePeriod and not longontrading  then

     

    and run both. You can easily see the difference.

     

    note that logic of code blocks is equivalent to:

    elsif buysignal and not realtrading and ordercount>equityCurvePeriod and not longontrading then

    You may switch each position of those conditions around. (and see the abnormal when buysignal is in 1st or 2nd position)

     

    I don’t know whether such abnormal is due to PRT’s intrinsic bug or maybe there is a basic rule for if… condition that I don’t know yet.

     

    Does someone know the cause? And how to avoid such unpredictable behavior?

     

    ps. also there is a bug in backtesting when running for i=0 to aNumberLargerThan500, the “i” will never exceed 500. Everyone can reproduce it by putting this code into backtesting :

    for i=0 to 999 do
        cantBiggerThan500 = i
    next
    graph cantBiggerThan500

    Is this bug will be fixed on next PRT version?

     

    Thanks!

    #92286 quote
    Nicolas
    Keymaster
    Legend

    Hi waid, thanks for the feedback about this issue. I moved your topic in the ProOrder forum since it is related to coding. I have no time now, but I will look deeper into your explanation by tomorrow.

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

abnormal behavior of if… and ..and ..and condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
waid @waid Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
7 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/25/2019
Status: Active
Attachments: No files
Logo Logo
Loading...