Announcement

Collapse
No announcement yet.

Moving average on oscilator

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

  • Moving average on oscilator

    Hello everyone,

    I am creating a price oscillator for the SPX based on Mr Angell formula which is very simple.

    ((High - Open) + (Close - Low)) / (2 * (High - Low))

    (We'll call that formula PO)

    So thats done, but now for the indicator to be significant I have to create a 13 period simple moving average of PO. That's when it gets tricky for me, I've tried many ways and I just can't do it.

    I dont know any prog language, which is why I use the Wizard. I enclosed the formula I've inputed and if anyone could help do that MA it'll be great.

    Thank you
    By the way this can be a great indicator for the SP500, please help to know more about it

  • #2
    Re: Moving average on oscilator

    jlsedm
    It is not possible to do that with the Formula Wizard as it can only use the builtin studies as the source for a study and not custom variables.
    In order to accomplish what you want you need to use the Editor. In your case the easiest way is to write a new efs in which you use the efsExternal() function to call the efs you posted. The reason this is the easiest solution is that you will not have to modify the script you have already written and can just use it to calculate your variable.
    PHP Code:
    function main(){
        var 
    myVar efsExternal("path to efs/name of efs.efs"); 
    This will create the series (ie myVar) that can then be used as the source of the moving average function sma() ie
    PHP Code:
    var myVar efsExternal("path to efs/name of efs.efs");
    var 
    myVarSMA sma(13myVar); 
    The variable myVarSMA will be the 13 period simple moving average of the custom variable myVar
    At this point return the two items to the chart ie
    PHP Code:
    return new Array (myVarmyVarSMA);

    For the description and syntax of the functions I mentioned [together with some examples of their use] see the respective links to the articles in the EFS KnowledgeBase. You can find further examples on the use of the efsExternal() function in this and this thread
    If -as you indicate - you are unfamiliar with programming in efs and you are interested in learning then I would suggest that you begin by reviewing the JavaScript for EFS video series and the Core JavaScript Reference Guide. Those 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.
    If at any time you have a question on a specific programming issue post it in the EFS Studies forum and someone will try to assist or guide you in resolving it.
    Alex


    Originally posted by jlsedm
    Hello everyone,

    I am creating a price oscillator for the SPX based on Mr Angell formula which is very simple.

    ((High - Open) + (Close - Low)) / (2 * (High - Low))

    (We'll call that formula PO)

    So thats done, but now for the indicator to be significant I have to create a 13 period simple moving average of PO. That's when it gets tricky for me, I've tried many ways and I just can't do it.

    I dont know any prog language, which is why I use the Wizard. I enclosed the formula I've inputed and if anyone could help do that MA it'll be great.

    Thank you
    By the way this can be a great indicator for the SP500, please help to know more about it

    Comment


    • #3
      Using Alex's input I put this together.

      Try it.

      var bInit = false;

      function preMain() {
      setPriceStudy(false);
      setStudyTitle("PO & 13SMA");
      setDefaultBarFgColor(Color.blue,0);
      setDefaultBarFgColor(Color.red,1);

      }
      function main(){
      if ( bInit == false ) {
      bInit = true;
      }
      myVar = efsInternal( "POCalc");
      myVarSMA = sma(13, myVar);


      return new Array (myVar, myVarSMA);
      }


      var vPOCalc = null;
      function POCalc(){
      vPOCalc = ((high() - open()) + (close() - low())) / (2 * (high() - low()))
      return vPOCalc;
      }
      Attached Files
      Last edited by waynecd; 05-22-2008, 08:34 AM.

      Comment


      • #4
        jlsedm
        Adding to the thread to explain what waynecd did.
        Rather than using the efsExternal() function to call the script you wrote he modified that by calculating the variable in a separate function within the same efs and then used the efsInternal() function to perform the same process I explained for the efsExternal() function.
        In the same links I provided in my earlier reply you will also find examples on the use of the efsInternal() function.
        Alex

        Comment


        • #5
          Waooo

          Thats super efficient.

          Thanks Alexis I did it in 10 minutes with your explanation. Its great I already tried the basic Java guide and didn't understand much, but just by doing that little program I think I got at least the first pages of the tutorial.

          Thanks waynecd as well, didn't see your post. I'm sure it is more efficient to use internal than external. Also if you trade the SP this can be a good indicator on a 30 minutes chart especially if you go with the trend (150 period expo MA is perfect to define trend). overbought is above 60 and below 40 for oversold;

          I use it along other indicators which is better.

          Have a great day everyone.
          Last edited by jlsedm; 05-22-2008, 09:01 AM.

          Comment


          • #6
            I should have explained, thanks Alex.

            Good tips jlsedm, I'll check them out.

            Comment


            • #7
              jlsedm

              Thanks Alexis I did it in 10 minutes with your explanation.
              You are most welcome.
              That is why I suggested to use efsExternal() as it did not imply changing anything of what you had already done.
              Another advantage of efsExternal() is that you will be able to call the same efs to create other indicators based on it without having to worry about integrating it into new scripts (naming of variables, etc)

              Its great I already tried the basic Java guide and didn't understand much, but just by doing that little program I think I got at least the first pages of the tutorial..
              This is the why I tend to prefer walking someone through creating a script rather than providing a completed formula. For those like you who are interested in learning this IMHO provides a better understanding of the process as you seem to confirm

              I'm sure it is more efficient to use internal than external.
              There is no discernable difference in terms of performance [that I am aware of] while efsExternal() holds a clear advantage in terms of ease of use.
              Alex


              Originally posted by jlsedm
              Thats super efficient.

              Thanks Alexis I did it in 10 minutes with your explanation. Its great I already tried the basic Java guide and didn't understand much, but just by doing that little program I think I got at least the first pages of the tutorial.

              Thanks waynecd as well, didn't see your post. I'm sure it is more efficient to use internal than external. Also if you trade the SP this can be a good indicator on a 30 minutes chart especially if you go with the trend (150 period expo MA is perfect to define trend). overbought is above 60 and below 40 for oversold;

              I use it along other indicators which is better.

              Have a great day everyone.

              Comment

              Working...
              X