Announcement

Collapse
No announcement yet.

Obv with a daily restart.

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

  • Obv with a daily restart.

    Hello
    I try to have a simple obv, with a daily restart ...
    so I have create a variable
    vdobv= "yesterday last obv"
    and I return obv-vdobv but it doesn't work .
    Coulld you tell where is the mistake..
    Thank you


    PHP Code:
    function preMain() {
     
     
    setPriceStudy(false);  
     
    setStudyTitle("OBV");  
     
    setCursorLabelName("OBV"0); 
     
    setDefaultBarFgColor(Color.blue0);
     
    setPlotType(PLOTTYPE_LINE,0);
     
    setDefaultBarThickness(1,0);
    }
    var 
    vobv null;
    var 
    vdobv null;

    function 
    main() { 
       
    vdobv obv(-1,close,inv("d"));  
       
    vobv =  obv() - vdobv
       return 
    vobv;


  • #2
    A slightly different approach should do it.

    Chris

    PHP Code:
    function preMain() {
     
     
    setPriceStudy(false);  
     
    setStudyTitle("OBV");  
     
    setCursorLabelName("OBV"0); 
     
    setDefaultBarFgColor(Color.blue0);
     
    setPlotType(PLOTTYPE_LINE,0);
     
    setDefaultBarThickness(1,0);
    }

    var 
    vobv     null;
    var 
    nLast    0;
    var 
    nStudy1 null;
    var 
    bInit     false;

    function 
    main() { 

        if ( 
    bInit == false ) {
        
            
    nStudy1 obv();
            
            
    bInit true;
            
        }
        
        if ( 
    getBarState()==BARSTATE_NEWBAR ) {
            
            if ( 
    getDay(0) != getDay(-1) ) {
                
    nLast nStudy1.getValue(-1);
            }
            
        }
            
        
    vobv nStudy1.getValue(0) - nLast;

       return 
    vobv;

    Comment


    • #3
      Thank you ,its working.

      Comment

      Working...
      X