Problem with condition

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #40345 quote
    Despair
    Blocked
    Master

    I have a strange problem. I want my condition to be true if a moving average goes flat (sideways). So i have something like:

    once i=0
    if ema=ema[1] then
      i=i+1
    endif
    graph ema as "ema"
    graph ema[1] as "ema[1]"
    graph i as "i"

    When i run the code the condition obviously never comes true since i remains zero all the time. Anyway when i look at the graphed variables the backtest shows many periods when ema=ema[1]. How can this be? Is that maybe that PRT intern calculates the emas with more than 5 digits and then cuts off the last digits when graphing them? This way there is a tiny difference between ema and ema[1] though graph shows the same value for them?

    This takes me to the question, with how many digits behind the comma is PRT calculating?

    #40355 quote
    Despair
    Blocked
    Master

    Obviously there is a problem with hidden digits. PRT shows 5 digits but internally it must calculate with more digits. Does anybody know with how many?

    #40374 quote
    robertogozzi
    Moderator
    Master

    Which TF did you use?

    I your assumption might be possible for very low TF’s, say 1 minute or lower, I think it would be extremely odd to have EMA’s matching the first 5 digits in a, say, 4-hour TF!

    #40381 quote
    Despair
    Blocked
    Master

    I was using 5 minute TF. And it is definitely th case with some hidden digits. When you graph the variables it comes back sometimes as “0” and sometimes as “-0.00” so obviously there is something going on one doesnt see (again!).

    #40392 quote
    robertogozzi
    Moderator
    Master

    I had to modify your code as follows to be executed:

    once i=0
    ema = average[20]
    if ema=ema[1] then
       i=i+1
    endif
    if i < 0 then
       buy 1 contract at market  //useless condition just to add a BUY order
    endif
    graph ema    as "ema"
    graph ema[1] as "ema[1]"
    graph i      as "i"

    I run it on DAX 5-min TF and it was executed regularly, I found a match on Friday July 7th at 09:35 (gmt +2), as from the picture.

    Variable i was set at 11, so there must have been 10 matches before.

    Prices seem regular with the full 5 digits + 5 decimal digits.

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

Problem with condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Despair @despair Blocked
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/11/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...