Announcement

Collapse
No announcement yet.

Monthly Pivots

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

  • Monthly Pivots

    I 've developed a efs- code for daily, weekly and monthly pivots.
    The daily and the weekly pivots are working fine, but if I let run the monthly pivots I am getting a "Window" with a message as follows: "Wrong Parameter" then eSignal shout down.

    I think the matter are these lines as follows:

    function preMain() {
    setStudyTitle("MONTHLY_PIVOT_ALERT");
    setPriceStudy(true);

    setCursorLabelName("R3-Monthly", 0);
    setCursorLabelName("R2-Monthly", 1);
    setCursorLabelName("R1-Monthly", 2);
    setCursorLabelName("PP-Monthly", 3);
    setCursorLabelName("S1-Monthly", 4);
    setCursorLabelName("S2-Monthly", 5);
    setCursorLabelName("S3-Monthly", 6);

    setDefaultBarStyle(PS_DASHDOTDOT, 0);
    setDefaultBarStyle(PS_DASHDOT, 1);
    setDefaultBarStyle(PS_DASH, 2);
    setDefaultBarStyle(PS_DASHDOT, 3);
    setDefaultBarStyle(PS_DASH, 4);
    setDefaultBarStyle(PS_DASHDOT, 5);
    setDefaultBarStyle(PS_DASHDOTDOT, 6);

    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setDefaultBarThickness(1, 3);
    setDefaultBarThickness(1, 4);
    setDefaultBarThickness(1, 5);
    setDefaultBarThickness(1, 6);

    setDefaultBarFgColor(Color.brown, 0);
    setDefaultBarFgColor(Color.brown, 1);
    setDefaultBarFgColor(Color.brown, 2);
    setDefaultBarFgColor(Color.olive, 3);
    setDefaultBarFgColor(Color.brown, 4);
    setDefaultBarFgColor(Color.brown, 5);
    setDefaultBarFgColor(Color.brown, 6);

    var iAlert = new FunctionParameter("iAlert", FunctionParameter.BOOLEAN);
    iAlert.setDefault( true );

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
    iDecimals.setDefault( 2 );
    iDecimals.setName("Round to X decimals");


    var iSymbol = new FunctionParameter("iSymbol", FunctionParameter.STRING);
    iSymbol.setDefault( "AAPL" );


    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
    iButtonX.setDefault( 150 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
    iButtonY.setDefault( 65 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
    iFontSize.setName("Button Font Size");
    iFontSize.setDefault( 10 );
    }

    var bInit = false;
    var xHigh = null;
    var xLow = null;
    var xClose = null;
    var xPP = null;
    var xR1 = null;
    var xS1 = null;
    var xR2 = null;
    var xS2 = null;
    var xR3 = null;
    var xS3 = null;

    function main(iAlert, iDecimals, iFontSize, iButtonX, iButtonY ) {
    // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
    drawTextPixel(iButtonX, iButtonY, " MONTHLY_PIVOT_ALERT @URL=EFS:editParameters", Color.white, Color.green,
    Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONT OP|Text.BOLD|Text.BUTTON,
    "Comic Sans MS", 13, "UpExp");

    return null;
    }


    xSymbol1 = getSymbol().toUpperCase() ;

    if(isMonthly() || isWeekly())
    return;


    if(bInit == false){
    xHigh = high(inv("M")); /*!!! Here appears the window "Wrong Parameter"!!!*/
    xLow = low(inv("M")); /*If you change the Parameter to "W" or "D" it works fine, but not with "M"!!!*/
    xClose = close(inv("M"));
    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;

    xPP = (vHigh+vLow+vClose)/3;
    xR1 = 2*xPP-vLow;
    xS1 = 2*xPP-vHigh;
    xR2 = (xPP-xS1)+xR1;
    xS2 = xPP-(xR1-xS1);
    xR3 = (2*xPP-vLow)-(vLow-vHigh);
    xS3 = (2*xPP-vHigh)-(vHigh-vLow);
    .....

    thank you for help in advance.

    Best regards

    Robert

  • #2
    Robert
    Are you located in a Timezone that is GMT +1 (or higher)?
    If that is the case then that error message and subsequent shut down are due to a known bug. For the description of the issue and an interim solution you may want to see this post
    Alex

    Comment

    Working...
    X