Announcement

Collapse
No announcement yet.

ReferenceError

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

  • ReferenceError

    Hi,
    i have got the message:
    "Line 26 ADX is not defined"
    Line 26 is
    "var myValue = ((1/adx(5, 2)).toFixed(2))*10;"


    What`s wrong?
    Thanks


    Is it possible to link a sound, if eg. ADX is
    above 40?



    function preMain() {

    setPriceStudy(true);
    setStudyTitle("ADX");




    }






    var bFlash = true;

    var myColor = Color.white;

    var mybgColor = Color.green;



    function main() {

    var myValue = ((1/adx(5, 0)).toFixed(2))*10;

    mybgColor = Color.white;



    if (bFlash == false) {

    if (myValue<=2) {

    //myColor = Color.black;

    mybgColor = Color.red;

    } else if (myValue>2 && myValue <= 4) {

    //myColor = Color.gray;

    mybgColor = Color.lime;

    } else if (myValue>4) {

    //myColor = Color.white;

    mybgColor = Color.navy;

    }

    bFlash = true;

    } else if (bFlash == true) {

    bFlash = false;

    }





    drawTextRelative( 0, AboveBar8, myValue , Color.black, mybgColor, Text.PRESET | Text.BOLD, null, 10, "text" );



    return;

    }

  • #2
    Bugeleisen
    Line 26 is not returning any errors that I can see when using ((1/adx(5, 2)).toFixed(2))*10.
    An error is returned in line 66 caused by the location flag AboveBar8 which is invalid (valid flags are AboveBar1 to AboveBar4).
    For the complete syntax of the drawTextRelative() function you may want to reference this article in the EFS KnowledgeBase
    Alex

    Comment


    • #3
      Bugeleisen

      Is it possible to link a sound, if eg. ADX is above 40?
      You can do that in many ways the simplest of which is to retrieve the value of the ADX directly in the condition eg
      PHP Code:
      if(adx(5,2,0)>40){//note that the third parameter is the bar index
          
      Alert.playSound("ding.wav");

      This alert will sound every time the condition is true. If you want it to sound only once per bar then you may want to see the method illustrated in the AlertOncePerBar.efs
      If instead you want it to sound only on completed bars then you would write the condition as follows
      PHP Code:
      if(getBarState()==BARSTATE_NEWBAR && adx(5,2,-1)>40){//note that the third parameter is the bar index
          
      Alert.playSound("ding.wav");

      In this case the third parameter (ie the bar index) is set to retrieve the value of the ADX at the prior bar once a new bar is formed. The alert will then sound only once on the first tick of a new bar
      Alex

      Comment

      Working...
      X