Announcement

Collapse
No announcement yet.

hhv & ComputeOnClose interaction

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

  • hhv & ComputeOnClose interaction

    When a chart closed at a new high in the last X bars and setComputeOnClose(true), the last bar does not appear to be counted towards the high. Problem does not occur on llv.

    I dont see anything wrong with the code.
    I have an image of the issue but am not sure where to upload it.


    PHP Code:
    var bInit false;
    var 
    xATR null;
    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Off by 1 ?");

        
    setShowCursorLabel(false);
        
    setComputeOnClose(true);
    //END preMain
    }


    function 
    main( ) {
    var 
    Length ;

    // misc Local vars
    var nHHigh;
    var 
    nLLow;

    // appears to be an off by 1 error in hhv&llv that exlude last bar at EOD?
    nHHigh hhvLengthhigh() );
    nLLow  llvLengthlow() );

    clearLines();
    clearText();

    debugPrint("nHHigh = " nHHigh " : nLLow = " nLLow "\n" );

        
    drawLineAbsolute( -(Length), nHHigh2nHHighPS_SOLID3Color.green,  10 );
        
    drawLineAbsolute( -(Length), nLLow,  2nLLow,  PS_SOLID3Color.maroon20 );  

        
    drawTextAbsolute( +2nHHigh"High: " nHHighColor.aquanullText.ONTOPnull1511 );      
        
    drawTextAbsolute( +2nLLow,  "Low: "  nLLow,  Color.aquanullText.ONTOPnull,1521 );      

        return ;
    //END main

    ick ... cant get rid of the html formating in the php/code ..
    best I can do.

    -Terry

  • #2
    Terry
    I am seeing the same behavior with both the hhv and llv ie the current bar is not counted towards the calculation of the highest High or lowest Low. This is to be expected when you enable setComputeOnClose() as the last bar being processed is at bar index -1.
    If this is not what you are seeing then you may want to attach an image that illustrates the issue. You can simply attach the image to a message by using the Attach file option which is available when you compose the message.
    As an aside keep in mind that the setComputeOnClose() function has no parameters so even if you were to write setComputeOnClose(false) it would still be enabled.
    With regards to the html formatting in the php/code that was appearing because you were using both the [ code ] and [ php] tags. You need to use just one or the other. I have corrected that issue in your post. I have also moved the thread to the EFS Studies forum which is the appropriate forum given the topic
    Alex


    Originally posted by thaynes
    When a chart closed at a new high in the last X bars and setComputeOnClose(true), the last bar does not appear to be counted towards the high. Problem does not occur on llv.

    I dont see anything wrong with the code.
    I have an image of the issue but am not sure where to upload it.


    PHP Code:
    var bInit false;
    var 
    xATR null;
    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Off by 1 ?");

        
    setShowCursorLabel(false);
        
    setComputeOnClose(true);
    //END preMain
    }


    function 
    main( ) {
    var 
    Length ;

    // misc Local vars
    var nHHigh;
    var 
    nLLow;

    // appears to be an off by 1 error in hhv&llv that exlude last bar at EOD?
    nHHigh hhvLengthhigh() );
    nLLow  llvLengthlow() );

    clearLines();
    clearText();

    debugPrint("nHHigh = " nHHigh " : nLLow = " nLLow "\n" );

        
    drawLineAbsolute( -(Length), nHHigh2nHHighPS_SOLID3Color.green,  10 );
        
    drawLineAbsolute( -(Length), nLLow,  2nLLow,  PS_SOLID3Color.maroon20 );  

     
    drawTextAbsolute( +2nHHigh"High: " nHHighColor.aquanullText.ONTOPnull1511 );      
     
    drawTextAbsolute( +2nLLow,  "Low: "  nLLow,  Color.aquanullText.ONTOPnull,1521 );      

        return ;
    //END main

    ick ... cant get rid of the html formating in the php/code ..
    best I can do.

    -Terry

    Comment


    • #3
      Thanks

      Appreciate the clarification on llv/hhv at behavor, was a little surprised that EOD did not close the bar. Oddly I did not get
      the same results on llv as hhv at EOD, but dont have picture.

      I use the true in ComputeOnClose() to remind myself,
      I comment it out when I dont want that behavor.

      Will watch the php/code in the future ...

      hope you have nice day,
      -Terry

      Comment


      • #4
        Re: Thanks

        Terry
        If by EOD you mean on the last bar of the day (ie trading session) then that condition in itself does not "close" a bar. A bar is considered closed by the efs engine only on the first tick of a new bar at which point the efs engine processes the bar that just closed.
        You too have a great day and weekend
        Alex


        Originally posted by thaynes
        Appreciate the clarification on llv/hhv at behavor, was a little surprised that EOD did not close the bar. Oddly I did not get
        the same results on llv as hhv at EOD, but dont have picture.

        I use the true in ComputeOnClose() to remind myself,
        I comment it out when I dont want that behavor.

        Will watch the php/code in the future ...

        hope you have nice day,
        -Terry

        Comment

        Working...
        X