Announcement

Collapse
No announcement yet.

Calculations on a variable

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

  • Calculations on a variable

    Is there a simple way to apply calculations (say, average of its values for the last 10 bars) to a variable that is NOT part of the return of any function?

    I am trying to define a (reusable) function with a generic input that does this.
    Any suggestions?
    Thanks.
    Mihai Buta

  • #2
    It's not clear to me exactly what you want here.

    If you are trying to create a generic MA function that you can call from any EFS and it will return the MA of the values the calling function sends, then it is doable, but you have to code the MA yourself. Luckily MA's are increadibly easy to code.

    If I were doing this (and I have done similar things, just not with MA's) I would use CallFunction() to call the MA.efs and pass the MA.efs an array of values that it would do its MA magic on.

    If you are trying to do something else, I would need more details.
    Garth

    Comment


    • #3
      What I want to is to define some generic functions, which I can re-use as building blocks, whever I need them.
      Here are a few examples:

      MyAverage = call ("myAverageFunction", AverageOf, AverageLength)

      MySlope = call("MySlopeFunction", SlopeOf, SlopeLength)

      The problem is refering inside the MyFunction to previous values of AverageOf or SlopeOf.
      I am used to TradeStation where you can pass ANY parameter to ANY function to create custom studies.

      Is there a similar way here?
      Thanks
      Last edited by mbuta; 02-09-2003, 02:50 AM.
      Mihai Buta

      Comment


      • #4
        I would just use localy defined global array (ie: one which is defined outside of a function) to store the values you need. In this way the values will be saved through interations of main().

        The calling program stuffs values into the array (you can use the array methods defined here , such as pop and push to help manipulate the defined array.

        The called function would loop through the array (and likely use the array property array.length to set the loop size up).

        I do this with numersous routines (such as volatility formula's and goodness of fit formula's).

        I would recommend you use callFunction() vs. call() when calling these reusable routines...for many reasons.
        Garth

        Comment


        • #5
          Re: Reply to post 'Calculations on a variable'

          Thanks G,
          I will try. I still see two problems:
          a/ Making the calculation only every 5min instead of each bar and
          b/ Finding the right values to calculate on.

          By the way, do you have any good efs formula vor volatility you want to
          email me? What is "goodness of fit"?
          Thanks.

          ----- Original Message -----
          From: <[email protected]>
          To: <[email protected]>
          Sent: Sunday, February 09, 2003 11:29 AM
          Subject: Reply to post 'Calculations on a variable'


          > Hello mbuta,
          >
          > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          >
          Mihai Buta

          Comment


          • #6
            I will try. I still see two problems:

            a/ Making the calculation only every 5min instead of each bar and
            Are you trying to run this on a 1 min. chart yet only have it calculate every five minutes? If so, just add a counter that increments when getBarState() shows that it is a NEWBAR. When the counter reaches 5 (or 4 if you start at 0) run your calculation and set the counter back to 1 (or 0).


            b/ Finding the right values to calculate on.
            I don't follow you here. If you are writing the formula, don't you know the values you need?
            Garth

            Comment


            • #7
              add a counter that increments when getBarState() shows that it is a NEWBAR

              I do this

              if (getMinute%5==0) then you have a new 5 minute interval, at least on a 1 minute chart

              Comment


              • #8
                That would work also...though I question what would happen in the unlikely event that you didn't get a price change at the even 5 minute period (eg: you got one at 10:19 and then one at 10:21, but not at 10:20).
                Garth

                Comment


                • #9
                  I would LOVE to see a solution to that issue

                  Comment


                  • #10
                    Re: Reply to post 'Calculations on a variable'

                    Thank you all guys. I will try your suggestions, although, I hate couters
                    and alike for EVERY one of the indicators (ADX is not the only one to look
                    at on evry bar/tick).
                    My concern is that the computer will start crashing long before I will be
                    able to implement half of what I need and then, I will realy hate all the
                    counters and arrays I had to sweat for.

                    I hope, I just hope that the efs environment will become more user friendly
                    and will let us be just traders with (some) programming abilities and not
                    require us to be expert programmers with no time for trading.
                    I started almost three weeks ago and I still was not able to put together a
                    reasonable strategy yet.
                    I have fragments (buiding blocks) but I find it very dificult task to glie
                    them together. Much more dificult than I expected.

                    ----- Original Message -----
                    From: <[email protected]>
                    To: <[email protected]>
                    Sent: Sunday, February 09, 2003 3:29 PM
                    Subject: Reply to post 'Calculations on a variable'


                    > Hello mbuta,
                    >
                    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    >
                    Mihai Buta

                    Comment


                    • #11
                      I don't think you have to worry about crashes. I have at least a six custom EFS formula's that are sitting at over 1000 lines of code (some well over 1000 lines), some of it very complex, and so far all works great (though I did have to bump up my heap and stack sizes). I have dozens of other customs EFS's that are shorter, and they all work well also.
                      Garth

                      Comment

                      Working...
                      X