Announcement

Collapse
No announcement yet.

current day calc prob and offset of lines drawn

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

  • current day calc prob and offset of lines drawn

    I believe these 2 issues might be somewhat related. The 1st is that the EFS generated R1/S1 and 10 day sma lines/values are incorrect throughout the current day but will be correct a day or so later.

    I also have a problem that the levels drawn by the 10 day sma routine, when at the correct level, are plotted a day behind.

    I would also like the lines drawn, to extend beyond the current bar so that they are more visable.

    Am new to Esignal and EFS, and would appreciate some guidance.

    Thanks,
    Steve

    =============================================
    PIVOTPOINTR1S1R3S3.EFS
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Pivot Points");
    setCursorLabelName("PP-R1", 0);
    setCursorLabelName("PP-S1", 1);
    setCursorLabelName("PP-R3", 2);
    setCursorLabelName("PP-S3", 3);

    // R3
    setDefaultBarStyle(PS_DASH, 2);
    setDefaultBarFgColor(Color.RGB(255,0,0), 2);
    setDefaultBarThickness(2, 2);

    // R1
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.RGB(210,255,210), 0);
    setDefaultBarThickness(28, 0);

    // S1
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.RGB(210,255,210), 1);
    setDefaultBarThickness(28, 1);

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

    // Start of Performance addition
    var vLastRawTime = null;
    var PP = null;
    var vLastPPR1 = null;
    var PPR2 = null;
    var vLastPPS1 = null;
    var PPS2 = null;
    var vLastPPR3 = null;
    var vLastPPS3 = null;
    var vLastArray = null;
    var vSymbol = null;
    var vInterval = null;
    var vReset = true;


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

    var nState = getBarState();
    if(vReset == true) {
    vLastRawTime = null;
    vLastArray = null;
    PP = null;
    vLastPPR1 = null;
    PPR2 = null;
    vLastPPS1 = null;
    PPS2 = null;
    vLastPPR3 = null;
    vLastPPS3 = null;
    vInterval = getInterval();
    vSymbol = getSymbol();
    vSymbol += ",D";
    vReset = false;
    }

    //vRawTime = getValue("rawtime"); // does not work properly with 1 min interval
    vRawTime = getDay();
    if(vRawTime == null)
    return;

    //vRawTime = Math.floor(vRawTime / RawTime.DAY);

    // Start of Performance addition
    if(vRawTime != null && vLastRawTime != null) {
    if(vRawTime == vLastRawTime) {
    return vLastArray;
    // return new Array(vLastPPR1, vLastPPS1, vLastPPR3, vLastPPS3);
    }
    }

    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);
    if(vIndex != null) {
    vH = getValueAbsolute("High", vIndex, vSymbol);
    vL = getValueAbsolute("Low", vIndex, vSymbol);
    vC = getValueAbsolute("Close", vIndex, vSymbol);
    if(vH != null && vL != null && vC != null) {
    PP = (vH + vL + vC) / 3;
    vLastPPR1 = 2 * PP - vL -.50;
    vLastPPS1 = 2 * PP - vH + .50;
    PPR2 = (PP - vLastPPS1) + vLastPPR1;
    PPS2 = PP - (vLastPPR1 - vLastPPS1);
    vLastPPR3 = (vLastPPR1 - PP) + PPR2;
    vLastPPS3 = PPS2 - (vLastPPR1 - PP);
    vLastRawTime = vRawTime;
    vLastArray = new Array(vLastPPR1, vLastPPS1, vLastPPR3, vLastPPS3);

    return vLastArray;
    }
    }
    }
    return null;
    }



    =============================================
    PBS.EFS
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("PB #s");
    setDefaultBarFgColor(Color.blue,0);
    setDefaultBarFgColor(Color.RGB(0,255,255),1);
    setDefaultBarFgColor(Color.RGB(0,255,255),2);
    setCursorLabelName("Pb #s");
    setDefaultBarThickness(2,0);
    setDefaultBarThickness(2,1);
    setDefaultBarThickness(2,2);
    }

    var vMA = null;
    var vMAH = null;
    var vMAL = null;

    function main(nLength, nPriceSource, nOffset) {
    if (nLength == null) {
    nLength = 9;
    } else {
    nLength = Math.abs(Math.round(nLength)) - 1;
    }
    if (nPriceSource == null)
    nPriceSource = "Close";
    if (nOffset == null)
    nOffset = 0;

    var vInterval = getInterval();
    if (vInterval == "D" || vInterval == "W" || vInterval == "M") return;

    if (getBarState() == BARSTATE_NEWBAR) {
    var vDay0 = getDay();
    var vDay1 = getDay(-1);
    if (vDay0 != vDay1) {
    var aData = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", nPriceSource, nOffset, nLength);
    if (aData == null) return;
    var dSum = 0;
    for (i = 0; i < nLength; ++i) {
    dSum += aData[i];
    }
    var c = call("/OHLC/getTodayOHLC1.efs", "Close");
    if (c == null) return;
    vMA = (dSum + c) / (nLength+1);
    vMAH = vMA + 25;
    vMAL = vMA - 25
    }
    }

    return Array(vMA, vMAH, vMAL);
    }



    =============================================
    GETPREVDAYSOHLC.EFS
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Get Previous Days OHLC");
    }

    var vSymbol = null;
    var vReset = true;

    function main(nPriceSource, nOffset, nNumDays) {
    if (nPriceSource == null)
    nPriceSource = "Close";
    if (nOffset == null) {
    nOffset = -1;
    } else {
    nOffset = (Math.abs(nOffset) * -1);
    }
    if (nNumDays == null) {
    nNumDays = 1;
    } else {
    nNumDays = Math.abs(nNumDays);
    }

    var nState = getBarState();
    if(vReset == true) {
    vDay1 = null;
    vSymbol = (getSymbol() + ",D");
    vReset = false;
    }

    vBarTime = getValue("time");
    if(vBarTime != null) {
    var vDay = vBarTime.getDay();
    if (vDay == 0) {
    var vDate = vBarTime.getDate();
    vDate -= 2;
    vBarTime.setDate(vDate);
    }
    var vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);
    if(vAbsTime == null) {
    return;
    }
    vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);
    if(vIndex != null) {
    var vValue = getValueAbsolute(nPriceSource, (vIndex + nOffset), -nNumDays, vSymbol);
    if(vValue == null) {
    return null;
    }
    }
    }

    return vValue;
    }
    Attached Files
Working...
X