Announcement

Collapse
No announcement yet.

Decimal Precision

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Decimal Precision

    In one test script, the same routine and same if statement evaluates the following differently. The statement is:

    if (xMA1.getValue(0)>xMA1.getValue(-1) ...

    Here are the values for each of the respective variables above. The if logical evaluation of each is shown in parens.

    21.1666397620307724 21.165679691824216 (true)

    21.2005191417841 21.194953182293844 (false)

    Both of these should evaluate as "true." Right?

    There are no other overriding statements that would affect the logical evaluation.

    Bob

  • #2
    Re: Decimal Precision

    Bob
    They are both evaluating to true at my end.
    Alex



    Originally posted by AssetHound
    In one test script, the same routine and same if statement evaluates the following differently. The statement is:

    if (xMA1.getValue(0)>xMA1.getValue(-1) ...

    Here are the values for each of the respective variables above. The if logical evaluation of each is shown in parens.

    21.1666397620307724 21.165679691824216 (true)

    21.2005191417841 21.194953182293844 (false)

    Both of these should evaluate as "true." Right?

    There are no other overriding statements that would affect the logical evaluation.

    Bob

    Comment


    • #3
      Re: Re: Decimal Precision

      Alex,

      Can I verify something quickly? For intra-day charts, the price of each new trade that comes in for a bar is captured using close(0).

      A bar could form by opening at a low price and rising to a higher close. For backtesting, you would realistically replace close(0) -- which is the tick price during the day -- with open(0) -- which would be closer to the actual start of a bar during trading hours (if what I said above happens).

      Looking at an after-hours 1-minute chart is not the same as looking at it during the day (as it forms). This might be some of my problem and I'll check it out. Thanks.

      Bob




      Originally posted by Alexis C. Montenegro
      Bob
      They are both evaluating to true at my end.
      Alex

      Comment


      • #4
        Re: Re: Re: Decimal Precision

        Bob

        For backtesting, you would realistically replace close(0) -- which is the tick price during the day -- with open(0) -- which would be closer to the actual start of a bar during trading hours (if what I said above happens).
        That would be true only if your conditions are based on the prior bar or on the Open of the current bar
        Alex


        Originally posted by AssetHound
        Alex,

        Can I verify something quickly? For intra-day charts, the price of each new trade that comes in for a bar is captured using close(0).

        A bar could form by opening at a low price and rising to a higher close. For backtesting, you would realistically replace close(0) -- which is the tick price during the day -- with open(0) -- which would be closer to the actual start of a bar during trading hours (if what I said above happens).

        Looking at an after-hours 1-minute chart is not the same as looking at it during the day (as it forms). This might be some of my problem and I'll check it out. Thanks.

        Bob

        Comment

        Working...
        X