Announcement

Collapse
No announcement yet.

Compare previous BB value with current

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

  • Compare previous BB value with current

    Hello everyone. I am very new to JavaScript programming and EFS. I hope someone can lend me a hand with these newbie questions. Sorry to make you guys bored.

    I have been trying to get the previous values for BB study (getValue(-1), (-2) etc...and my purpose is to compare them with current value (0)) but it doesn't seem to work with the code i have written. What is wrong?

    Maybe someone can also point me to some helpful EFS programming resources?
    Thanks in advance
    .......

    var ubb85 = null;
    var mbb85 = null;
    var lbb85 = null;
    var test = false;

    function main() {
    var ubb85_1;
    var mbb85_1;
    var lbb85_1;

    if (test == false) {
    ubb85 = upperBB(85, 2)
    mbb85 = middleBB(85, 2)
    lbb85 = lowerBB(85, 2)
    test = true;
    }

    ubb85_1 = ubb85.getValue(-1)
    mbb85_1 = mbb85.getValue(-1)
    lbb85_1 = lbb85.getValue(-1)

    ......

  • #2
    Re: Compare previous BB value with current

    jzn1
    While there are no syntax errors in those lines of code the script is incomplete as is. All it is currently set to do is to initialize the upper, middle and lower Bollinger series and assign them to some global variables and retrieve the prior bar's values from these series and assign them to some local variables. There is no return statement (if you are trying to plot the indicator) and the main function is missing a closing curly bracket. There is no code logic to compare the values of the prior bar to those of the current bar and it is not clear from the brief description you provided what you are trying to accomplish which makes it somewhat difficult to offer any suggestions.
    Anyhow I added a return statement and the missing curly bracket and as you can see in the enclosed screenshot that code is working.
    If - as you indicate - you are new to programming in EFS you may want to review the JavaScript for EFS video series and the Core JavaScript Reference Guide. These will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
    Alex




    Originally posted by jzn1
    Hello everyone. I am very new to JavaScript programming and EFS. I hope someone can lend me a hand with these newbie questions. Sorry to make you guys bored.

    I have been trying to get the previous values for BB study (getValue(-1), (-2) etc...and my purpose is to compare them with current value (0)) but it doesn't seem to work with the code i have written. What is wrong?

    Maybe someone can also point me to some helpful EFS programming resources?
    Thanks in advance
    .......

    var ubb85 = null;
    var mbb85 = null;
    var lbb85 = null;
    var test = false;

    function main() {
    var ubb85_1;
    var mbb85_1;
    var lbb85_1;

    if (test == false) {
    ubb85 = upperBB(85, 2)
    mbb85 = middleBB(85, 2)
    lbb85 = lowerBB(85, 2)
    test = true;
    }

    ubb85_1 = ubb85.getValue(-1)
    mbb85_1 = mbb85.getValue(-1)
    lbb85_1 = lbb85.getValue(-1)

    ......

    Comment


    • #3
      Thank you Alex.

      I will look through the reference material to gain a deeper understanding.

      Comment


      • #4
        jzn1
        You are most welcome
        Alex


        Originally posted by jzn1
        Thank you Alex.

        I will look through the reference material to gain a deeper understanding.

        Comment

        Working...
        X