Announcement

Collapse
No announcement yet.

2005 Feb: The Truth About Volatility

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

  • #31
    Hello acetrader2,

    The best place to start learning more about JavaScript, which is the foundation of EFS, would be our EFS KnowledgeBase. You will find the Core JavaScript Guide in the Core JavaScript 1.5 folder. This guide will teach you everything you need to know about the JavaScript language, syntax and what variables are, etc. Once you have a basic understanding of the language then you should be ready to start using the EFS extensions to access the chart data and performing other EFS tasks such as Alerts. To learn more about a specific EFS function, you will find that information under the EFS 2 Function Reference folder. This will give you the syntax as well as some code examples for each function. The other guide that you will find helpful is the Guide to Developing EFS Indicators, which will also cover more EFS basics. After you have gone through these guides, start trying different things in the EFS editor. As you run into specific obstacles that you don't understand, post your questions and code here and one of the moderators or other members of the forums will help provide some guidance or suggestions.

    As for the pop up alert in the formula you previously posted. Start over with a fresh copy of Alex's formula (volatilityentryadvisor(alerts).efs) and just add the Alert.addToList() function with hard coded values like below.

    PHP Code:
    if (nState == BARSTATE_NEWBAR) {
        
    //begin section added by ACM
        
    vColor2=vColor1;
        
    vColor1=vColor;
        if(
    vColor1!=vColor2){
            
    Alert.playSound("ding.wav");
            
    Alert.addToList(getSymbol(), "Alert!"Color.redColor.black);
        } 
        
    //end added by ACM      

    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


    • #32
      Jason,

      Thanks for the info. I have done what you suggest and it's working except I get the alert sound and pop-up on every new bar after a color change. How to change the code so that there is only one alert... when the bar changes color? Here's the code:

      PHP Code:
      /*****************************************************************
      Provided By : eSignal (c) Copyright 2004
      Description:  Volatility Entry Advisor - by Jim Berg

      Version 1.1

      Notes:
      2/15/2005 - Added setComputeOnClose()

      February 2005 Issue - "The Truth About Volatility"

      Formula Parameters:                 Defaults:
      ATR Periods                         10
      LL and HH Periods                   20
      Thickness                           2
      *****************************************************************/

      function preMain() {
          
      setPriceStudy(true);
          
      setStudyTitle("Volatility Entry Advisor ");
          
      setCursorLabelName("Entry"0);
          
      setCursorLabelName("Exit"1);
          
      setDefaultBarThickness(20);
          
      setDefaultBarThickness(21);
          {
      setDefaultBarFgColor(Color.green0);
          
      setDefaultBarFgColor(Color.khaki1);}
          
          
      setColorPriceBars(true);
          
      setDefaultPriceBarColor(Color.grey);
          
      setComputeOnClose();
          
          
      setShowTitleParameters(false);
          
          
      // Formula Parameters
          
      var fp1 = new FunctionParameter("nATRlen"FunctionParameter.NUMBER);
              
      fp1.setName("ATR Periods");
              
      fp1.setLowerLimit(1);
              
      fp1.setDefault(10);
          var 
      fp2 = new FunctionParameter("nDonlen"FunctionParameter.NUMBER);
              
      fp2.setName("LL and HH Periods");
              
      fp2.setLowerLimit(1);
              
      fp2.setDefault(20);

          
      // Study Parameters
          
      var sp1 = new FunctionParameter("nThick"FunctionParameter.NUMBER);
              
      sp1.setName("Thickness");
              
      sp1.setDefault(2);
      }

      var 
      bEdit true;
      var 
      vATR null;
      var 
      vDonchian null;
      var 
      vColor Color.grey;
      var 
      vColor1 null;//added by ACM
      var vColor2 null;//added by ACM

      function main(nATRlennDonlennThick) {
          if (
      bEdit == true) {
              
      vATR = new ATRStudy(nATRlen);
              
      vDonchian = new DonchianStudy(nDonlen0);
              
      setDefaultBarThickness(nThick0);
              
      setDefaultBarThickness(nThick1);
              
      bEdit false;
          }
          
          var 
      nState getBarState();
          if (
      nState == BARSTATE_NEWBAR) {
                  
      //begin section added by ACM
              
      vColor2=vColor1;
              
      vColor1=vColor;
              if(
      vColor1!=vColor2){
                  
      Alert.playSound("train.wav");
                  
      Alert.addToListgetSymbol(), " :ATR Bar Change"Color.blackColor.purple);
              } 
              
      //end added by ACM      
          
      }
          
          var 
      ATR vATR.getValue(ATRStudy.ATR);
          var 
      HHV vDonchian.getValue(DonchianStudy.UPPER);
          var 
      LLV vDonchian.getValue(DonchianStudy.LOWER);
          if (
      ATR == null || HHV == null || LLV == null) return;
          
          var 
      vEntryLine LLV+(2*ATR);
          var 
      vExitLine HHV-(2*ATR);
          var 
      close();
          
          if (
      vEntryLine) {
              
      vColor Color.blue;
          } else if (
      vExitLine) {
              
      vColor Color.red;
          }
          
      setPriceBarColor(vColor);
          
          
      //return;
          
      return new Array(vEntryLinevExitLine);

      Comment


      • #33
        acetrader2
        Actually the alerts trigger only once at every change of color however they trigger one bar late so if for example you have a red-blue-red-red-red pattern you end up with the impression that it is triggering alerts on the same colored bars whereas it is still referncing prior color changes.
        This happens because when I first added the section of code that generates the triggers to the original efs it did not have setComputeOnClose(). Once setComputeOnClose() was added to the script it delayed all the alerts by one bar.
        Here is how to fix this issue

        1. Comment out the global variable var vColor2 = null;//added by ACM as it is no longer required.
        2. From the following section of code in your script

        PHP Code:
        var nState getBarState();
            if (
        nState == BARSTATE_NEWBAR) {
                    
        //begin section added by ACM
                
        vColor2=vColor1;
                
        vColor1=vColor;
                if(
        vColor1!=vColor2){
                    
        Alert.playSound("train.wav");
                    
        Alert.addToListgetSymbol(), " :ATR Bar Change"Color.blackColor.purple);
                } 
                
        //end added by ACM      
            

        2a. Copy the following and paste it in your efs after the line setPriceBarColor(vColor);

        PHP Code:
        if(vColor!=vColor1){
                
        Alert.playSound("train.wav");
                
        Alert.addToListgetSymbol(), " :ATR Bar Change"Color.blackColor.purple);
            } 
        2b. Comment out ALL the lines leaving ONLY the following

        PHP Code:
         vColor1=vColor
        Once you implement these changes the alerts will trigger on the same bar in which the color changes.
        If you encounter any problems post the code as you have modified it and someone will be available to help
        Alex

        Comment


        • #34
          Alexis, I've done as you suggest and receive an error:

          Line81 SyntexError: invalid return: if (ATR == null || HHV == null || LLV == null) return;

          Following is the code changed per your suggestions:

          /************************************************** ***************
          Provided By : eSignal (c) Copyright 2004
          Description: Volatility Entry Advisor - by Jim Berg

          Version 1.1

          Notes:
          2/15/2005 - Added setComputeOnClose()

          February 2005 Issue - "The Truth About Volatility"

          Formula Parameters: Defaults:
          ATR Periods 10
          LL and HH Periods 20
          Thickness 2
          ************************************************** ***************/

          function preMain() {
          setPriceStudy(true);
          setStudyTitle("Volatility Entry Advisor ");
          setCursorLabelName("Entry", 0);
          setCursorLabelName("Exit", 1);
          setDefaultBarThickness(2, 0);
          setDefaultBarThickness(2, 1);
          {setDefaultBarFgColor(Color.green, 0);
          setDefaultBarFgColor(Color.khaki, 1);}

          setColorPriceBars(true);
          setDefaultPriceBarColor(Color.grey);
          setComputeOnClose();

          setShowTitleParameters(false);

          // Formula Parameters
          var fp1 = new FunctionParameter("nATRlen", FunctionParameter.NUMBER);
          fp1.setName("ATR Periods");
          fp1.setLowerLimit(1);
          fp1.setDefault(10);
          var fp2 = new FunctionParameter("nDonlen", FunctionParameter.NUMBER);
          fp2.setName("LL and HH Periods");
          fp2.setLowerLimit(1);
          fp2.setDefault(20);

          // Study Parameters
          var sp1 = new FunctionParameter("nThick", FunctionParameter.NUMBER);
          sp1.setName("Thickness");
          sp1.setDefault(2);
          }

          var bEdit = true;
          var vATR = null;
          var vDonchian = null;
          var vColor = Color.grey;
          var vColor1 = null;//added by ACM
          //var vColor2 = null;//added by ACM

          function main(nATRlen, nDonlen, nThick) {
          if (bEdit == true) {
          vATR = new ATRStudy(nATRlen);
          vDonchian = new DonchianStudy(nDonlen, 0);
          setDefaultBarThickness(nThick, 0);
          setDefaultBarThickness(nThick, 1);
          bEdit = false;
          }

          var nState = getBarState();
          if (nState == BARSTATE_NEWBAR) {
          //begin section added by ACM
          //vColor2=vColor1;
          vColor1=vColor;
          //if(vColor1!=vColor2){
          //Alert.playSound("train.wav");
          //Alert.addToList( getSymbol(), " :ATR Bar Change", Color.black, Color.purple);
          }
          //end added by ACM
          }

          var ATR = vATR.getValue(ATRStudy.ATR);
          var HHV = vDonchian.getValue(DonchianStudy.UPPER);
          var LLV = vDonchian.getValue(DonchianStudy.LOWER);
          if (ATR == null || HHV == null || LLV == null) return;

          var vEntryLine = LLV+(2*ATR);
          var vExitLine = HHV-(2*ATR);
          var c = close();

          if (c > vEntryLine) {
          vColor = Color.blue;
          } else if (c < vExitLine) {
          vColor = Color.red;
          }
          setPriceBarColor(vColor);
          if(vColor!=vColor1){
          Alert.playSound("train.wav");
          Alert.addToList( getSymbol(), " :ATR Bar Change", Color.black, Color.purple);
          }

          //return;
          return new Array(vEntryLine, vExitLine);
          }

          Comment


          • #35
            acetrader2
            From the section of code that I indicated you still need to comment out the remaining lines leaving ONLY the line with vColor1=vColor;. Once you do that you will no longer get a syntax error
            Alex

            Comment


            • #36
              Hi Guys,

              I've studied the article by Jim Berg and been using various colour charts before (inc XTL in AGET and TTM Trend) I have to say I'm very impressed with your efs. Really great. I'd allways used a 12 period bollinger band off highs to base a long profit target to offer out. Your volatility profit target is excellent.

              I also like JasonK's entry lines - a great visual on the chart to strengthen the trade probability of the colour change.

              Can you add both alerts (pop up) and the entry lines?

              I'd really appreciate it. It's a great day trade system.

              I really appreciate what you've written. Really top stuff.

              Cheers

              James

              Comment


              • #37
                I've attched an efs which i've played with - combines both pop-up/alerts and the entry lines. Seems to work fine; but I'm no IT wizard.

                JasonK, I can't find an explaination of your khaki line in your efs entry advisor?

                Again, really apreciate everyone's input on this site. Thx

                James

                Comment


                • #38
                  here it is
                  Attached Files

                  Comment


                  • #39
                    think I'm posting to myself on this one. However, I've figured the Green (entry) & Khaki (exit) lines. It was when a stock was trading between the two that had me flummexed. All is crystal now. Thx JasonK.

                    Kind Rgds, James

                    Comment


                    • #40
                      2 year 3 Month time lag

                      Jason,

                      Considering there was a 2 year 3 month time lag between the las t post and yours, I can understand why it seems like your posting to yourself.

                      But I find this thread fascinating and the scripts are great. Good work and thanks for your help.

                      John O
                      Baltimore, MD

                      Comment


                      • #41
                        Volatility Entry Advisor W/O Alert

                        Would it be possible to have the Volatility Entry Advisor efs work with out the pop triggered alert list?
                        Enclosed is the efs formula.
                        /************************************************** ***************
                        Provided By : eSignal (c) Copyright 2004
                        Description: Volatility Entry Advisor - by Jim Berg

                        Version 1.1

                        Notes:
                        2/15/2005 - Added setComputeOnClose()

                        February 2005 Issue - "The Truth About Volatility"

                        Formula Parameters: Defaults:
                        ATR Periods 10
                        LL and HH Periods 20
                        Thickness 2
                        ************************************************** ***************/

                        function preMain() {
                        setPriceStudy(true);
                        setStudyTitle("Volatility Entry Advisor ");
                        setCursorLabelName("Entry", 0);
                        setCursorLabelName("Exit", 1);
                        setDefaultBarThickness(2, 0);
                        setDefaultBarThickness(2, 1);
                        setDefaultBarFgColor(Color.green, 0);
                        setDefaultBarFgColor(Color.khaki, 1);

                        setColorPriceBars(true);
                        setDefaultPriceBarColor(Color.grey);
                        setComputeOnClose();

                        setShowTitleParameters(false);

                        // Formula Parameters
                        var fp1 = new FunctionParameter("nATRlen", FunctionParameter.NUMBER);
                        fp1.setName("ATR Periods");
                        fp1.setLowerLimit(1);
                        fp1.setDefault(10);
                        var fp2 = new FunctionParameter("nDonlen", FunctionParameter.NUMBER);
                        fp2.setName("LL and HH Periods");
                        fp2.setLowerLimit(1);
                        fp2.setDefault(20);

                        // Study Parameters
                        var sp1 = new FunctionParameter("nThick", FunctionParameter.NUMBER);
                        sp1.setName("Thickness");
                        sp1.setDefault(2);
                        }

                        var bEdit = true;
                        var vATR = null;
                        var vDonchian = null;
                        var vColor = Color.grey;

                        function main(nATRlen, nDonlen, nThick) {
                        if (bEdit == true) {
                        vATR = new ATRStudy(nATRlen);
                        vDonchian = new DonchianStudy(nDonlen, 0);
                        setDefaultBarThickness(nThick, 0);
                        setDefaultBarThickness(nThick, 1);
                        bEdit = false;
                        }

                        var nState = getBarState();
                        if (nState == BARSTATE_NEWBAR) {
                        }

                        var ATR = vATR.getValue(ATRStudy.ATR);
                        var HHV = vDonchian.getValue(DonchianStudy.UPPER);
                        var LLV = vDonchian.getValue(DonchianStudy.LOWER);
                        if (ATR == null || HHV == null || LLV == null) return;

                        var vEntryLine = LLV+(2*ATR);
                        var vExitLine = HHV-(2*ATR);
                        var c = close();

                        if (c > vEntryLine) {
                        vColor = Color.blue;
                        } else if (c < vExitLine) {
                        vColor = Color.red;
                        }
                        setPriceBarColor(vColor);

                        //return;
                        return new Array(vEntryLine, vExitLine);
                        }
                        Thanks...Greg

                        Comment


                        • #42
                          Hello Greg,

                          The formula code you've posted does not have Alert.addToList() function calls present, which generates pop-up alerts. At any rate, if you were referring to some other formula code in this thread, you can disable the pop-ups by deleting that line of code or add two forward slashes (i.e. //) to the front of that line to disable it.

                          //Alert.addToList(...

                          These forward slashes are referred to as a single line comment. Commented code does not get executed by the formula engine. Hope this helps.
                          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


                          • #43
                            Volatility Entry Advisor W/O Alert

                            JasonK;
                            Thanks for the reply. The efs does give me a pop up alert. It says "ATR bar change". Trigger time and symbol.
                            So I'm trying to find out which part of the efs code to add the "//" to. Like you said, it does not have Alert.addToList() function. So that's where I'm confused.
                            Thanks again...Greg

                            Comment


                            • #44
                              Volatility Entry Advisor W/O Alert

                              JasonK;
                              Disregard my last posting. Just figured it out.
                              Thanks again...greg

                              Comment


                              • #45
                                Hi Jason

                                I've been using the volatility entry advisor efs (inc the green & khaki entry/exit lines) and have noticed a slight anomaly

                                Now I'm a user rather than programmer, so I'm really asking your help.

                                First (long entry) - if a stock trades up/thru the green entry line it turns blue (regardless of the the khaki exit/short entry line being above or below the price). ie. entry parameters are satisfied. 2xATR(10) abv LLV(20).

                                However (short entry) - if a stock trades down/thru the kharki it only turns red when "additionally" also below the green. so not strictly adhering to 2xATR(10) blw HHV(20). So the formula is favouring the long side.

                                Could you (please) adjust the efs so that the short colour change to red is "only" based on the kharki short entry criteria as per the long entry is only relative to the green? Or guide me to make the change myself.

                                I've added the in-error short entry to visually show the anomaly. You can see that the blue bar closes below the khaki but doesn't turn red. This only happens when the green is below the khaki and when already blue bars.

                                kind regards

                                James
                                Attached Files
                                Last edited by James 88; 11-08-2007, 03:58 AM.

                                Comment

                                Working...
                                X