Announcement

Collapse
No announcement yet.

Multi-TimeFrame question

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

  • Multi-TimeFrame question

    Hi

    A fews questions I'd really appreciate help with ...

    1) If I am running a 15 min chart can I lopp through say the last 150 1 hour bars - if I find a particular pattern i want to draw a line from one of those bars to the current bar.

    2) What is the best way of converting bar(n) on one timeframe to bar(m) on a diferent time frame ... e.g. bar -8 on a 15 min chart would convert to bar -2 on a 1 hour chart.

    3) What is the best way to adjust the end point of a line already drawn ...

    Many Thanks

    Paul

  • #2
    Hope these help..

    1) If I am running a 15 min chart can I lopp through say the last 150 1 hour bars - if I find a particular pattern i want to draw a line from one of those bars to the current bar.

    You would use a simple formula to calculate the location of that "pattern bar".

    One thing that is very important in developing EFS files with lots of graphics use is to COUNT THE BARS on the chart. I do this with this bit of code.

    PHP Code:
     var nBarCounter 0;

    function 
    main()
    {
         if ( 
    getBarState() == BARSTATE_NEWBAR ) {
            
    nBarCounter ++;
         }
    //  end of main. 
    Now that you have code to count the bars on the chart, it's simply a matter of subtracting the total bar count from the bar that identified your pattern. Say for example you loop back to find a pattern on bar 133 and the current number of bars is 287.

    You would simply use (133-287) to identify the location of the "pattern bar" and draw a line to the current bar (0) - like this.

    PHP Code:
       drawLineRelative((pattern_bar-nBarCounter),close((pattern_bar-nBarCounter)),0,close(), PS_SOLID2Color.blue"Example"+nBarCounter); 

    2) What is the best way of converting bar(n) on one timeframe to bar(m) on a diferent time frame ... e.g. bar -8 on a 15 min chart would convert to bar -2 on a 1 hour chart.

    This requires a "lookup" feature. I calculate the "Total number of minutes" in the time stamp of that bar, then use simple math to find the match. Here is some sample code.

    PHP Code:

    function fMakeTotalMinutes(nHournMinnSec) {
      return (
    nHour*60)+nMin+(nSec/100);

    This will return a FLOAT value like 431.45 or 213.08.

    Now, you need a lookup function to find the similar time on the other chart.

    PHP Code:

    function fLookupTimeBar nTimeinMinutes ) {
       var 
    0;  //  initiate pointer at current bar
       
    var foundlessertime false;

       while (!
    foundlessertime) {
          if ( 
    fMakeTotalMinutes getHour(x), getMinute(x), getSeconds(x) ) <= nTimeinMinutes) {
             
    foundlessertime true;
          }
         
    x--;
       }

    //  The result of this function will always be 1 less than the actual matching bar because of the while loop.  
    //  So the final result will need to be increased by 1 to be accurate.

      
    return (x+1);

    3) What is the best way to adjust the end point of a line already drawn ...

    Just "redraw" the line with the same TAG value. The TAG value (at the end) is a combination of text and numbers that are used to identify the line. In the example above, I'm using the nBarCounter value (thus allowing me to draw unique lines on every bar), but I could easly change this to simply TEXT or a different combination of text/numbers to create unique IDs for different lines.

    I like to use the DAY value for lines that are unique throughout the entire day - like ("DailyHH"+getDay()). This would represent a unique HIGHEST HIGH value for the DAY.

    Let me know if these helped you out a bit?
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X