Announcement

Collapse
No announcement yet.

Problrm getting Open,High,Low,Close with getValueAbsolute

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

  • Problrm getting Open,High,Low,Close with getValueAbsolute

    I modified Woodie_Pivots.efs to use different pivot calculations. This EFS runs with no errors, but the values I get for Open and Low are the highs for the bars that have the open and low during a 24 hour period. I'm not sure what is returned for the Close, but I know it's incorrect. I want my close value to be the open value for the first bar at midnight (00:00). (I'm using this EFS to draw pivot points on forex charts)

    Anybody able to help me out?


    /************************
    Copyright © eSignal, 2003
    *************************/

    /*
    Description: Contains Pivot Points based on theories by
    H = YesterdaysHigh
    L = YesterdaysLow
    C = TodaysOpen

    PP = (H + L + C) / 3

    R1 = (PP x 2) - L
    Rm3 = (PP - R1)/2 + R1
    R2 = PP + R1 - S1
    Rm4 = (R1 - R2)/2 + R2
    R3 = 2 x PP + (H - (2 x L))
    Rm = (Rm4 - R3)/2 + R3

    S1 = (PP x 2) - H
    Sm2 = (S1 - PP)/2 + PP
    S2 = PP - R1 + S1
    Sm2 = (S2 - S1)/2 + S1
    S3 = 2 X PP - ((2 X H) - L)
    Sm = (S3 - S2)/2 + S2

    */


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Pivots2");
    setCursorLabelName("R3", 0);
    setCursorLabelName("Rm", 1);
    setCursorLabelName("R2", 2);
    setCursorLabelName("Rm4", 3);
    setCursorLabelName("R1", 4);
    setCursorLabelName("Rm3", 5);
    setCursorLabelName("PP", 6);
    setCursorLabelName("Sm2", 7);
    setCursorLabelName("S1", 8);
    setCursorLabelName("Sm1", 9);
    setCursorLabelName("S2", 10);
    setCursorLabelName("Sm", 11);
    setCursorLabelName("S3", 12);


    // R3
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.RGB(255,0,255), 0);
    setDefaultBarThickness(3, 0);

    // Rm
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.purple, 1);
    setDefaultBarThickness(2, 1);

    // R2
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.maroon, 2);
    setDefaultBarThickness(2, 2);

    // Rm4
    setDefaultBarStyle(PS_SOLID, 3);
    setDefaultBarFgColor(Color.red, 3);
    setDefaultBarThickness(2, 3);

    // R1
    setDefaultBarStyle(PS_SOLID, 4);
    setDefaultBarFgColor(Color.teal, 4);
    setDefaultBarThickness(2, 4);

    // Rm3
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarFgColor(Color.blue, 5);
    setDefaultBarThickness(2, 5);


    // Bain Pivot Point
    setDefaultBarStyle(PS_SOLID, 6);
    setDefaultBarFgColor(Color.grey, 6);
    setDefaultBarThickness(3, 6);

    // Sm2
    setDefaultBarStyle(PS_SOLID, 7);
    setDefaultBarFgColor(Color.blue, 7);
    setDefaultBarThickness(2, 7);

    // S1
    setDefaultBarStyle(PS_SOLID, 8);
    setDefaultBarFgColor(Color.teal, 8);
    setDefaultBarThickness(2, 8);

    // Sm1
    setDefaultBarStyle(PS_SOLID, 9);
    setDefaultBarFgColor(Color.red, 9);
    setDefaultBarThickness(2, 9);

    // S2
    setDefaultBarStyle(PS_SOLID, 10);
    setDefaultBarFgColor(Color.maroon, 10);
    setDefaultBarThickness(2, 10);

    // Sm
    setDefaultBarStyle(PS_SOLID, 11);
    setDefaultBarFgColor(Color.purple, 11);
    setDefaultBarThickness(2, 11);

    // S3
    setDefaultBarStyle(PS_SOLID, 12);
    setDefaultBarFgColor(Color.RGB(255,0,255), 12);
    setDefaultBarThickness(3, 12);
    }

    // Start of Performance addition
    var vLastRawTime = null;
    var vLastPP = null;
    var vLastPPR1 = null;
    var vLastPPR2 = null;
    var vLastPPR3 = null;
    var vLastPPS1 = null;
    var vLastPPS2 = null;
    var vLastPPS3 = null;
    var vLastPPRm3 = null;
    var vLastPPRm4 = null;
    var vLastPPRm = null;
    var vLastPPSm2 = null;
    var vLastPPSm1 = null;
    var vLastPPSm = null;
    var vLastArray = null;
    var vSymbol = null;
    var vInterval = null;
    var vReset = true;


    function main() {
    var vH;
    var vL;
    var vC;
    var vO;
    var vRawTime;
    var vBarTime;
    var vIndex;

    var nState = getBarState();
    if(vReset == true) {
    vLastRawTime = null;
    vLastArray = null;
    vLastPP = null;
    vLastPPR1 = null;
    vLastPPR2 = null;
    vLastPPR3 = null;
    vLastPPS1 = null;
    vLastPPS2 = null;
    vLastPPS3 = null;
    vLastPPRm3 = null;
    vLastPPRm4 = null;
    vLastPPRm = null;
    vLastPPSm2 = null;
    vLastPPSm1 = null;
    vLastPPSm = null;
    vInterval = getInterval();
    vSymbol = getSymbol();
    vSymbol += ",D";
    vReset = false;
    }

    vRawTime = getDay();
    if(vRawTime == null)
    return;

    // Start of Performance addition
    if(vRawTime != null && vLastRawTime != null) {
    if(vRawTime == vLastRawTime) {
    return vLastArray;
    }
    }

    if(vInterval == null)
    return null;

    if(vInterval == "D")
    return null;

    if(vInterval == "W")
    return null;

    if(vInterval == "M")
    return null;

    if(vInterval == "T")
    return null;

    vBarTime = getValue("time");
    if(vBarTime != null) {
    var vDay = vBarTime.getDay();
    if (vDay == 0) {
    var vDate = vBarTime.getDate();
    vDate -= 2;
    vBarTime.setDate(vDate);
    }
    vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);
    if(vAbsTime == null) {
    return;
    }
    vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);
    var vIndex2 = getFirstBarIndexOfDay(vBarTime, vSymbol);
    if(vIndex != null) {
    vH = getValueAbsolute("high", vIndex, vSymbol);
    vL = getValueAbsolute("low", vIndex, vSymbol);
    vO = getValueAbsolute("open", vIndex, vSymbol);
    vC = getValueAbsolute("open", vIndex2, vSymbol);


    if(vH != null && vL != null && vO != null && vC != null) {
    vLastPP = (vH + vL + vC) / 3;
    vLastPPR1 = (2 * vLastPP) - vL;
    vLastPPRm3 = (vLastPP - vLastPPR1) / 2 + vLastPPR1;
    vLastPPS1 = (2 * vLastPP) - vH;
    vLastPPS2 = vLastPP - (vLastPPR1 - vLastPPS1);
    vLastPPR2 = vLastPP + (vLastPPR1 - vLastPPS1);
    vLastPPS3 = (2 * vLastPP) - ((2*vH) - vL);
    vLastPPR3 = (2 * vLastPP) + (vH - (2 * vL));
    vLastPPRm4 = (vLastPPR1 - vLastPPR2)/2 + vLastPPR2;
    vLastPPRm = (vLastPPR2 - vLastPPR3)/2 + vLastPPR3;
    vLastPPSm2 = (vLastPPS1 - vLastPP)/2 + vLastPP;
    vLastPPSm1 = (vLastPPS2 - vLastPPS1)/2 + vLastPPS1;
    vLastPPSm = (vLastPPS3 - vLastPPS2)/2 + vLastPPS2;
    vLastRawTime = vRawTime;
    vLastArray = new Array(vLastPPR3, vLastPPRm,vLastPPR2,vLastPPRm4, vLastPPR1,vLastPPRm3, vLastPP,vLastPPSm2, vLastPPS1,vLastPPSm1, vLastPPS2,vLastPPSm,vLastPPS3);

    if (vC > vO) {
    drawTextRelative(-1,vLastPPSm2,"M2",Color.RGB(0x00,0x00,0xFF),null,T ext.ONTOP,"Arial",16);
    drawTextRelative(-1,vLastPPRm4,"M4",Color.RGB(0x00,0x00,0xFF),null,T ext.ONTOP,"Arial",16);
    drawTextRelative(-1,vLastPPSm1,"M1",Color.RGB(0x00,0x80,0x00),null,T ext.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPRm3,"M3",Color.RGB(0x00,0x00,0x00),null,T ext.ONTOP,"Arial",12);
    }else{
    drawTextRelative(-1,vLastPPSm1,"M1",Color.RGB(0xFF,0x80,0x00),null,T ext.ONTOP,"Arial",16);
    drawTextRelative(-1,vLastPPRm3,"M3",Color.RGB(0xFF,0x00,0x00),null,T ext.ONTOP,"Arial",16);
    drawTextRelative(-1,vLastPPSm2,"M2",Color.RGB(0x00,0x00,0x00),null,T ext.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPRm4,"M4",Color.RGB(0x00,0x00,0x00),null,T ext.ONTOP,"Arial",12);
    }

    drawTextRelative(-1,vLastPP,"PP",Color.RGB(0x00,0x00,0x00),null,Text .ONTOP,"Arial",16);
    drawTextRelative(-1,vLastPPR1,"R1",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPR2,"R2",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPRm,"Rm",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPR3,"R3",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPS1,"S1",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPS2,"S2",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPSm,"Sm",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);
    drawTextRelative(-1,vLastPPS3,"S3",Color.RGB(0x00,0x00,0x00),null,Te xt.ONTOP,"Arial",12);

    // these lines are for debuging
    drawTextRelative(-20,vLastPP,"O= " + vO,Color.RGB(0x00,0x00,0x00),null,Text.ONTOP,"Aria l",12);
    drawTextRelative(-20,vLastPPS1,"H= " + vH,Color.RGB(0x00,0x00,0x00),null,Text.ONTOP,"Aria l",12);
    drawTextRelative(-20,vLastPPSm1,"L= " + vL,Color.RGB(0x00,0x00,0x00),null,Text.ONTOP,"Aria l",12);
    drawTextRelative(-20,vLastPPS2,"C= " + vC,Color.RGB(0x00,0x00,0x00),null,Text.ONTOP,"Aria l",12);
    drawTextRelative(-20,vLastPPR1,"vBarTime= " + vBarTime,Color.RGB(0x00,0x00,0x00),null,Text.ONTOP ,"Arial",12);

    return vLastArray;
    }



    }
    }
    return null;
    }
Working...
X