Announcement

Collapse
No announcement yet.

custom mathematical functions

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

  • custom mathematical functions

    Hi,

    I'm new to this board and my backgroud is Tradestation2000i ELS. I'm wondering if any of you experts out there can point me to the right direction.

    I want to learn how to write my own (external) function in efs, so that it can be called by any formula or studies or strategies. For example, if I want to create a mathematical function called MyRSI(parm1, parm2), and MyRSI() can be called from any other formulas/studies/strategies.

    Thank you in advance.

    William

  • #2
    William
    The easiest way to do that in efs is to use the efsExternal() function. See the link for the required syntax.
    You can also find detailed information and examples in this thread which is specifically dedicated to the efsExternal() and efsInternal() functions and in this thread which includes some examples of studies on studies that use the efsExternal() function.
    Alex

    Comment


    • #3
      Thank you, Alex.

      Those are very good links. There are a great deal of material for me to study. I'm slowing digesting them.

      At first glance, EFS seems to be a little more cumbersom, or less intuitive from traders standpoint, than ELS (Tradestation) for example. For traders who do not have strong programming background, it can be daunting to program their strategy. However, having said that, I think EFS allows for more control.

      I see that the variables declared before main() and premain() are global variables, but they are not global variables in the sense that they can be referenced in other formulas/strategies. These global variables are only global within the code. My question is, would it be possible to have a true global variable where it can be reference in other formulas or studies?

      Anothe question:
      let's say I have already developed MyRSI() external function. How would I get the the value of MyRSI() value in the current bar, the previous bar, 2 bars from away, etc? What's the syntax?

      As you can see, I'm still learning to program EFS.

      Thank you in advance.

      William

      Comment


      • #4
        William

        My question is, would it be possible to have a true global variable where it can be reference in other formulas or studies?
        For that use the setGlobalValue() and getGlobalValue() functions.

        How would I get the the value of MyRSI() value in the current bar, the previous bar, 2 bars from away, etc? What's the syntax?
        To do that you use the .getValue(barIndex) method where barIndex is the index of the bar you want to retrieve eg -1 for 1 bar ago, -2 for two bars ago, etc. See the example enclosed below
        Alex


        PHP Code:
        var myVar efsExternal("myEFS.efs"param1param2);
        var 
        myVarCurrent myVar.getValue(0);//current value of myVar
        var myVarPrevious myVar.getValue(-1);//prior value of myVar
        //etc 

        Comment

        Working...
        X