Announcement

Collapse
No announcement yet.

wrong high/low being returned

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

  • wrong high/low being returned

    Hi,

    In the attached image you will note that the high/low is not correctly returned by the following script regardless of use of BARSTATE_NEWBAR, or high(0)/high(-1) or low(0)/low(-1).

    I need the study to return the price bar high of the bar when stochs %K is below the 20 and is crossing up through %D and the price bar low when %K is above the 80 and %K is crossing down under the %D.

    Any help is greatly appreciated.

    wayne

    PHP Code:
    function preMain() {
    setStudyTitle("TEST - Stochastic");
    setDefaultBarStyle(PS_SOLID0);
    setDefaultBarStyle(PS_SOLID1);
    setDefaultBarFgColor(Color.blue0);
    setDefaultBarFgColor(Color.red1);
    setDefaultBarThickness(10);
    setDefaultBarThickness(11);
    setPlotType(PLOTTYPE_LINE0);
    setPlotType(PLOTTYPE_LINE1);
    }
    var 
    vStochK null;
    var 
    vStochD null;
    var 
    bInit false;
    var 
    vHigh 0;
    var 
    vHigh_1 0;
    var 
    vLow 0;
    var 
    vLow_1 0;
    vTrigger 0;

    function 
    main() {

        if(
    bInit == false){
            
    setCursorLabelName("%K ",0)
            
    setCursorLabelName("%D ",1)
            
    setCursorLabelName("H ",2)
            
    setCursorLabelName("H_1 ",3)
            
    setCursorLabelName("L ",4)
            
    setCursorLabelName("L_1 ",5)
            if(
    vStochK==nullvStochK stochK(1433);
            
    vStochK getSeries(vStochK);
            if(
    vStochD==nullvStochD stochD(1433);
            
    vStochD getSeries(vStochD);
            
    addBand80PS_SOLID1Color.black,2);
            
    addBand20PS_SOLID1Color.black,3);
        }
        
    xHigh high(0);
        
    xLow low(0);
        
    xHigh_1 high(-1);
        
    xLow_1 low(-1);
        if(
    vStochK.getValue(-1) > vStochD.getValue(-1) && vStochK.getValue(0) < vStochD.getValue(0) && vStochK.getValue(0) > 80){
            
    setBarBgColor(Color.RGB(246168188)); // light red 
            
    vTrigger 1
        
    }else if(vStochK.getValue(-1) < vStochD.getValue(-1) && vStochK.getValue(0) > vStochD.getValue(0) && vStochK.getValue(0) < 20){
            
    setBarBgColorColor.RGB(178243171)); // light green
            
    vTrigger = -1
        
    }else vTrigger 0;
    //    if(getBarState() == BARSTATE_NEWBAR){
            
    if(vTrigger == 1){
                
    vHigh xHigh;
                
    vHigh_1 xHigh_1;
            }    
            else if(
    vTrigger == -1){
                
    vLow xLow;
                
    vLow_1 xLow_1;
            }
            else{
                
    vHigh 0;
                
    vHigh_1 0;
                
    vLow 0;
                
    vLow_1 0;
    //        }
        
    }    
        return new Array(
    vStochK,vStochD,vHigh.toFixed(),vHigh_1.toFixed(),vLow.toFixed(),vLow_1.toFixed());

    Attached Files

  • #2
    Hi wayne,

    You have toFixed() your self in your return statement. two fix it (yuk, yuk), try toFixed(2)...

    Comment


    • #3
      Hi Steve,

      That did it.

      Couldn't resist it, eh?

      lol.

      Thanks

      wayne

      Comment


      • #4
        Hi wayne,

        Your righT, it Was far toO tempting 2 pass up...

        Good to hear you enjoyed it.

        Comment

        Working...
        X