Announcement

Collapse
No announcement yet.

several ma:s

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

  • several ma:s

    Hi! I try to learn Javascript but would like to know if it works fast enough for my needs before i spend to many hours learning it.

    Could you show me how to write a script with 100 moving averages (2-100) in the same chart as the bars? Same color and based on close.

    How would this be programmed to work very fast when i change intervalls from 1 min to 60 etc?

    Thank you very much!

  • #2
    You don't need to use JavaScript for this moving average request, just add the ma's to a chart, change time intervals and the ma's will change.

    I also don't think the chart will be readable with 100 ma's on it, but I could be wrong.

    PS It is just as tedious to write a program to do this as it is to manually add them to the chart.

    Comment


    • #3
      Following up on David's message.
      If instead you really want them as an efs attached is a "starter kit" with averages 2 through 5 done with Formula Wizard.
      Open it with the Formula Wizard and just keep on adding...
      Alex
      Attached Files

      Comment


      • #4
        Hi! Thanks! It´s not possible to make a loop or something so it´s not needed to write every single ma? Which one will be the fastest?

        Comment


        • #5
          I have no idea if it is possible to create a loop to do this.
          Of the methods suggested a guess is that David's is probably faster.
          Having said that I would make well sure that chart never gets corrupted...
          Alex

          Comment


          • #6
            I wrote and EFS that drew a bunch of rsi lines for someone using a loop. I'm sure if you do a search you can find it in this BB someplace (that thread is about 1 month old). So it is possible, and it really isn't all that painful to do. However, I suspect the results of this request as with that one, aren't really interesting from a TA standpoint.

            Garth
            Garth

            Comment


            • #7
              Hi Garth,
              I think this is the RSI study that you wrote.

              Paul
              Attached Files

              Comment


              • #8
                Hi Paul,

                Yep that's the one, thanks.

                All that really needs to happen is for the builtin definitions to be changed to MA's and for the loop's to be changed to the MA lengths (and of course have those sizes be reflected in the MA's paramter list).

                If the original poster wants to give changing it a try, it should be pretty straight forward. I would do it, but I have two projects I am working on right now, and don't have a lot of time this weekend to even work on those...

                G
                Garth

                Comment


                • #9
                  Hi! Can this formula be used? Thank you







                  var myRSIStudy = new Array();
                  var myRSIValues = new Array();
                  var vInit = false;

                  //== preMain function use to define defaults
                  function preMain()
                  {
                  setStudyTitle("MultiRSI");

                  /*
                  * Set the properties of the default bar. These will be the
                  * properties of any bar for which style, color, thickness is
                  * not specificed.
                  */
                  var i=0;
                  for (i = 0; i <=21; i++){
                  setCursorLabelName("RSI-" + (i+5), i);
                  setDefaultBarFgColor(Color.RGB((i+180),(i*10),(i*1 0)), i); // These might make some UGLY colors
                  setDefaultBarStyle(PS_SOLID,i);
                  }
                  /* Uncomment the statement below this to make it a price study! */
                  // setPriceStudy(true);

                  }

                  //== Main Function - EFS workhorse
                  function main() {

                  if (vInit == false) {
                  for (i=0;i<=21; i++) {
                  myRSIStudy[i] = new RSIStudy(5+i,"Close");
                  }

                  vInit = true;
                  }

                  for (i=0;i<=21; i++){
                  myRSIValues[i] = myRSIStudy[i].getValue(RSIStudy.RSI);
                  }

                  return myRSIValues;

                  Comment


                  • #10
                    Hi Gspiker! I used the first formula but when i change between 1-5-60 minutes in the chart it works very slow. This formula that i pasted below works much faster. But i have no idea how to change it for ma.

                    Comment


                    • #11
                      Yes it can be used. They are basically the same study but on the one you posted someone stripped out my copyright info ;-0 and added the vinit lines. The vinit was a good idea on someone's part...I should have thought of it myself..better yet I should have just checked for getBarState() == BARSTATE_ALLBARS ...which would be the better way to do that.

                      Look in your formula directory under builtin's to see how to use the built in studies in EFS. In this case I am using RSI and you want to use MA...so I would look at the MA study or the RSI study.

                      If you can wait for a week or so I might do this...and it should be pretty quick once I can work on it...but I have other things I am working on right now.

                      G
                      Garth

                      Comment

                      Working...
                      X