Announcement

Collapse
No announcement yet.

Time Frame Interval

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

  • Time Frame Interval

    I have been working on EFS that places moving average in study pane (non Plot). I am having problems when changing time frames on chart. When in 60 min (4 period SMA up last 4 hrs) when change to daily ( 4 period on 60 min now up last 6 hrs). I need help understanding how interval in EFS2@ works. Please see attached EFS. Thanks in advance
    Attached Files

  • #2
    Hello wr101,

    When your sma study is set to the 60 minute interval, the specified nIndex used with .getValue(nIndex) calls reference the corresponding bar index from the 60 minute chart when running on the daily interval. The comparison of the 0 to the -1 values of the sma are comparing the last two 60 minute sma values from within that day, not the last 60 minute sma value for that day compared to the last 60 minute sma value from the previous day.

    It will help you see it visually if you create a test formula and plot the 60 minute sma studies on a daily chart and compare the same formula on a 60 minute chart. Try something like below.

    PHP Code:
    function preMain() {
        
    setStudyTitle("test");
        
    setPriceStudy(true);
        
    }


    function 
    main() {
        var 
    xAvgr1c1  smainv(60) ) ;

        if( 
    xAvgr1c1.getValue(0)  > xAvgr1c1.getValue(-1) ) {
            
    setBarFgColor(Color.red0);
            
    debugPrintln(getCurrentBarIndex() + "  " xAvgr1c1.getValue(-1)  + "  " xAvgr1c1.getValue(0))
        }
           
        return 
    xAvgr1c1;

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X