Announcement

Collapse
No announcement yet.

At the open of the bar how can we know what the bar's high is?

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

  • At the open of the bar how can we know what the bar's high is?

    The 'BackTesting2_ClosingPositions.pdf' [the link is EFS & Backtest docs on the Forum] has been very helpful. However the example code has the following logic which appears to me to be unrealistic [ie] IF THE CURRENT BAR'S HIGH IS EQUAL TO OR GREATER THAN ........ go long with a limit order ........ AT THE OPEN OF THE BAR, ......

    My question is: "At the open of the bar how can we know what the bar's high is?
    Please advise me as to whether this is reasonable or faulty logic.

    The code block to which I am referring is:

    if (high(0) >= nU) { // Long Trade Signal
    /*
    if the current bar's high is equal to or greater than the previous bar's
    Upper Donchian channel, go long with a limit order at the value of the
    previous bar's Upper Donchian value or the open of the bar, which ever is
    greater.
    */
    Strategy.doLong("Long Signal", Strategy.LIMIT, Strategy.THISBAR,
    Strategy.DEFAULT, Math.max(nU, open(0)) );

  • #2
    Re: At the open of the bar how can we know what the bar's high is?

    jcm21

    My question is: "At the open of the bar how can we know what the bar's high is?
    Please advise me as to whether this is reasonable or faulty logic.
    The logic is not faulty in as much as a back test is performed on completed bars only. In this case that logic allows you to define the price to use to approximate more closely a real time condition.
    In fact if the Open of the bar is greater than the previous bar's Upper Donchian then you would need to use the former as the entry price as it would be the trade that breaches the entry line. If instead the Open is lower than the previous bar's Upper Donchian but the High of the bar is greater than the previous bar's Upper Donchian then you can use the latter as the entry price because the market presumably traded across the entry line.
    Hope this helps
    Alex


    Originally posted by jcm21
    The 'BackTesting2_ClosingPositions.pdf' [the link is EFS & Backtest docs on the Forum] has been very helpful. However the example code has the following logic which appears to me to be unrealistic [ie] IF THE CURRENT BAR'S HIGH IS EQUAL TO OR GREATER THAN ........ go long with a limit order ........ AT THE OPEN OF THE BAR, ......

    My question is: "At the open of the bar how can we know what the bar's high is?
    Please advise me as to whether this is reasonable or faulty logic.

    The code block to which I am referring is:

    if (high(0) >= nU) { // Long Trade Signal
    /*
    if the current bar's high is equal to or greater than the previous bar's
    Upper Donchian channel, go long with a limit order at the value of the
    previous bar's Upper Donchian value or the open of the bar, which ever is
    greater.
    */
    Strategy.doLong("Long Signal", Strategy.LIMIT, Strategy.THISBAR,
    Strategy.DEFAULT, Math.max(nU, open(0)) );

    Comment


    • #3
      Thanks Alex - I see my error.

      Hi Alex & thanks for the input,

      I see my error. I mis-read the following statement. Now it makes sense.

      "if the current bar's high is equal to or greater than the previous bar's
      Upper Donchian channel, go long with a limit order at the value of the
      previous bar's Upper Donchian value or the open of the bar, which ever is
      greater.

      Comment


      • #4
        Re: Thanks Alex - I see my error.

        jcm21
        You are most welcome
        Alex


        Originally posted by jcm21
        Hi Alex & thanks for the input,

        I see my error. I mis-read the following statement. Now it makes sense.

        "if the current bar's high is equal to or greater than the previous bar's
        Upper Donchian channel, go long with a limit order at the value of the
        previous bar's Upper Donchian value or the open of the bar, which ever is
        greater.

        Comment

        Working...
        X