Announcement

Collapse
No announcement yet.

Centre of Gravity Oscillator + Color Bars

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

  • Centre of Gravity Oscillator + Color Bars

    I am trying to use the CoG oscillator to color bars for a change in trend - but my syntax is pretty poor, I just added 2 lines to the standard efs.

    Here is my code - any help would be great.
    Attached Files

  • #2
    Hello pmurraymc,

    To get you past the syntax error, change the upper case "I" for the if() statement on line 82 to a lower case "i."
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks for that, but I have obviously missunderstood what the two variables in the returned array mean - I just wanted to check the signal line against the main line.

      Paul

      Comment


      • #4
        Hello Paul,

        The next issue you're dealing with has to do with the formula logic. The two if() statements you've added are after the return statements in main(), which prevents them from being executed. The best way to trouble shoot, or debug, code is by using the debugPrintln() function. If you were to place a debugPrintln("some message") between the return logic and your two conditional if() statements, you wouldn't receive the message, "some message," printed to the Formula Output Window (Tools-->EFS menu). By moving the debugPrintln() statement further up the chain in the order of process, eventually you will get the message printed to the output window. This process will help you pin point the section of code that is causing a problem, or at least not performing in the manner in which you are expecting.

        For your code example, I would move the two conditional statements inside the code block where vRef[0] gets returned, since we know it will have a valid value inside that code block. Also place them before the return statement so they will get evaluated before main ends at that return statement. Try the code modification below. You will see that the conditional statements you created and the onAction() functions should now execute.

        PHP Code:
            vRef ref(-1); 
            
            if(
        vRef == null) {   
                return new Array(
        dCGnull);
            } else {
                if (
        vRef[0] < dCGonAction1();
                if (
        vRef[0] > dCGonAction2();
              return new Array(
        dCGvRef[0]);
            }

        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Hello Jason,

          thanks for the help, I have now moved the code but still get no colored bars. Sorry to be a pain - I have included the code.

          Paul.
          Attached Files

          Comment


          • #6
            Hello Paul,

            No problem, I'm happy to help. Thanks for posting your code. From what I'm seeing the formula is coloring the price bars red and blue. If you wanted to color the background of each bar in the study pane instead of the price bars, try replacing the setPriceBarColor() functions in your onAction functions to setBarBgColor().

            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Seems that it does work after all, thanks for the help and the de-bugging tip.

              Paul

              Comment

              Working...
              X