Announcement

Collapse
No announcement yet.

Different Formulas for Different Time Interval Charts

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

  • Different Formulas for Different Time Interval Charts

    I use about 4 different time frames, daily, weekly, monthly and intraday time frames. For example, I may use a 200 DMA on a daily, but would like to use a 40 DMA on a weekly. I have a three or four formulas per time frame.

    What is the best/easiest way to automatically change length or other formula inputs with different time frames?

    A programming example would be great.

    Thanks

  • #2
    Re: Different Formulas for Different Time Interval Charts

    usgvince
    You can do that with a set of conditional statements that evaluate the interval and set a variable that is used as the Length parameter of the moving average function.
    For a basic example of the required logic copy the code enclosed below and paste it in the main function of the the basicMA(s).efs formula which is included in the EFS2 Basic folder of Formulas.
    PHP Code:
    var Length;
    var 
    Interval getInterval();

        if(
    Interval == "D"Length 200;
        else if (
    Interval == "W"Length 40;
        else if (
    Interval == "M"Length 10;
        else if (
    isIntraday()) Length 300;
        else 
    Length 100
    Then in the formula replace the line
    PHP Code:
    return sma(10); 
    with
    PHP Code:
    return sma(Length
    and save the formula with a new name. Apply the formula to the chart and it will change the length of the moving average as you change the chart to those intervals
    Alex


    Originally posted by usgvince
    I use about 4 different time frames, daily, weekly, monthly and intraday time frames. For example, I may use a 200 DMA on a daily, but would like to use a 40 DMA on a weekly. I have a three or four formulas per time frame.

    What is the best/easiest way to automatically change length or other formula inputs with different time frames?

    A programming example would be great.

    Thanks

    Comment

    Working...
    X