Announcement

Collapse
No announcement yet.

EFS error

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

  • EFS error

    Hello,

    I have the following code. It gives me a invalid array. What am I doing wrong? When i do Array(1), it works well but I don't give any values.

    -Mike


    function main() {
    var nNumberBars;
    var nIndex = getCurrentBarIndex();

    nNumberBars = getNumBars();

    // if (bInit == false) {
    KS = middleDonchian(27);
    buffer = atr(5);
    //drawShapeRelative(0,high(0)+buffer, Shape.SQUARE,null,Color.blue,Shape.TOP);
    if (close(0) > KS.getValue(0) )
    {
    dotvalue = KS - buffer;
    drawShapeRelative(0,dotvalue, Shape.CIRCLE,null,Color.green,Shape.TOP)
    } else {

    dotvalue = KS + buffer;
    drawShapeRelative(0,dotvalue, Shape.CIRCLE,null,Color.green,Shape.TOP)
    }


    return new Array(dotvalue);

    }

  • #2
    Hi Mike,
    PHP Code:
    var bInit=false;
    var 
    KS,buffer;//make these global so they are available each iteration of main
    function main() {
        var 
    nNumberBars;
        var 
    nIndex getCurrentBarIndex();

        
    nNumberBars getNumBars();

        if (
    bInit == false) {//use "bInit" routine to create the series only once
            
    KS middleDonchian(27);
            
    buffer atr(5); 
        }
        
    //drawShapeRelative(0,high(0)+buffer, Shape.SQUARE,null,Color.blue,Shape.TOP);
        
    if (close(0) > KS.getValue(0) )
        {
            
    dotvalue KS.getValue(0) - buffer.getValue(0);//last value is needed not the full series
            
    drawShapeRelative(0,dotvalueShape.CIRCLE,null,Color.green,Shape.TOP)
        } else {
            
    dotvalue KS.getValue(0) + buffer.getValue(0);//last value is needed not the full series
            
    drawShapeRelative(0,dotvalueShape.CIRCLE,null,Color.green,Shape.TOP)
        }


        return 
    dotvalue;//don't use "new Array(...)" when returning only one value


    Wayne

    Comment


    • #3
      Little tidbit. When you have multiple values to return, this:

      return new Array(val1, val2, ...);

      is the same as this:

      return [val1, val2, ...];

      Comment

      Working...
      X