Announcement

Collapse
No announcement yet.

Using vars for interval in 7.9

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

  • Using vars for interval in 7.9

    Hi,

    I tried to use a variable for interval in a study in 7.9 in I got crashed.

    I am using multiple intervals, which vary based on the base interval (eg. 2/5/15, 5/15/30, 15/30/60, 30/60/D) and want to simplify my code [and make it more accurate].

    Can anybody clarify if using a variable in inv() is prohibited?

    If this is the case, I find it a serious limitation in an, otherwise, beautiful feature

    Thank you.

    Mihai Buta
    Mihai Buta

  • #2
    Mihai
    Post the efs or a complete example of code that reproduces the problem and someone can take a look at it
    Alex

    Comment


    • #3
      It is straight forward using a variable "M1" instead of a fixed interval.

      var M1 = 15;
      studyCCI = cci(10, close(0,inv("M1")));

      Using M1 simple I get crashed, using "M1" it gives compilation error with "invalid parameter".

      Note: I was using the formula widzard provided in efs editor.

      Thank you.

      Mihai Buta
      Mihai Buta

      Comment


      • #4
        Mihai
        You are using an incorrect syntax because you are passing a single value ie close(0,inv("M1")) instead of a series ie close(inv(M1)) which the study requires. The following shows how you can use a variable for inv()
        You may also want to look at the sample efs(s) that are provided in the EFS2 Custom folder that are fully customizable (through variables) for interval and/or symbol
        Alex

        PHP Code:
        function preMain() {
            
        setPriceStudy(false);
            
        setStudyTitle("CCI");
            
        setCursorLabelName("CCI"0);
        }

        function 
        main() {

            var 
        M1 15;

            var 
        vCCI cci(20,close(inv(M1)));

            return 
        vCCI;

        Comment


        • #5
          Mihai
          Another issue is that by passing the string "M1" the efs sees the "M" as Month so the resulting plot will be the CCI based on monthly data and not on 15 minute. You may want to use letters other than D, W, M or T for the variable names if you are passing them as a string.
          Alex

          Comment


          • #6
            Thank you Alex,

            As I did not have any other reference, I was using what the f(x) widzard produced.

            Can you tell me where that "EFS2 Custome folder" is located?

            Thank you again,
            Mihai
            Mihai Buta

            Comment


            • #7
              Mihai
              With regards to the new EFS2 functions you may want to read through the EFS2 Function Reference in the EFS KnowledgeBase. BTW that whole section is also available by clicking the Help icon in the Formula Editor
              The EFS2 Custom folder is in the Formulas folder
              Alex

              Comment


              • #8
                Thank you Alex,

                I did read the documents you refer to, before I tried to code in EFS2, but there are no examples that show that variables can be used and how to use them, for data series.

                Mihai
                Mihai Buta

                Comment

                Working...
                X