Announcement

Collapse
No announcement yet.

Pivot Points

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

  • Pivot Points

    I'm trying to make pivot point in my intraday chart. I have made this far, but something isn't working. can anyone direct my to right direction.

    Thanks,

    Billy


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Pivot Range");
    setCursorLabelName("Pivot Range");
    setCursorLabelName("PR High",0);
    setCursorLabelName("PR Low",1);
    setDefaultBarStyle(PS_SOLID,0);
    setDefaultBarFgColor(Color.black,0);
    setDefaultBarThickness(2,0);
    setPlotType(PLOTTYPE_FLATLINES,0);
    setDefaultBarStyle(PS_SOLID,1);
    setDefaultBarFgColor(Color.black,1);
    setDefaultBarThickness(2,1);
    setPlotType(PLOTTYPE_FLATLINES,1);
    }

    // initialization flag
    var bInit = false;

    // global variables for series objects
    var xHigh = null;
    var xLow = null;
    var xClose = null;

    function main() {

    if (bInit == false) { // initialization routine occurs only once.
    Symbol = getSymbol();
    Interval = "D";
    var vSymbol = Symbol+","+Interval;
    xHigh = high(-1,sym(vSymbol));
    xLow = low(-1,sym(vSymbol));
    xClose = close(-1,sym(vSymbol));

    bInit = true;
    }

    var pHigh = xHigh.getValue(0);
    var pLow = xLow.getValue(0);
    var pClose= xClose.getValue(0);

    pivotRangeDiff = ((pHigh + pLow + pClose) / 3) - ((pHigh + pLow) / 2);
    pivotRangeHigh = ((pHigh + pLow + pClose) / 3) + pivotRangeDiff;
    pivotRangeLow = ((pHigh + pLow + pClose) / 3) - pivotRangeDiff;

    return new Array(pivotRangeHigh,pivotRangeLow);
    }
    Last edited by buzybill; 06-17-2007, 08:28 AM.

  • #2
    Hi
    There are some examples in the Formuas\Pivots directory. In PivotPoints.efs see different use of high(), low() and close(), your "-1" needs dropping. and since you are using the same symbol, "inv()" is enough.
    PHP Code:
        if(bInit == false){
            
    xHigh  high(inv("D"));
            
    xLow   low(inv("D"));
            
    xClose close(inv("D")); 
            
    bInit true;
        }
        
        var 
    vHigh  xHigh.getValue(-1);
        var 
    vLow   xLow.getValue(-1);
        var 
    vClose xClose.getValue(-1); 
        if(
    vHigh == null || vLow == null || vClose == null)
        return; 
    Good luck
    Dave

    Comment

    Working...
    X