Announcement

Collapse
No announcement yet.

Using Date functions from one timeframe in higher and lower timeframes

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

  • Using Date functions from one timeframe in higher and lower timeframes

    I'm looking for an elegant streamlined solution to plot lines based on values at specific dates on a chart from one timeframe into another whether it is a higher or lower timeframe from which the values have been derived.

    At the moment I have been forced to use the addBand() function, although good, is not exactly what I want, and all I have come up with as an alternative, is horribly complex and ultimately cpu intensive. So if anyone has a nicer solution it would be much appreciated.

    Requirements to plot data in any timeframe using drawLineRelative() function from the specific bar index where the value has been derived from to the current bar. If this is impossible because of intraday data only being available for 6 months, then from the first bar of the series to the current bar:-

    1. End of Year Pivot

    2. Quarterly Pivots

    3. 52 Week High/Low

    Here is a code fragment which works in daily charts for Requirements 1 and 2 above, but will not work in any other timeframe and addBand() has to be used:-

    // ****************************************
    if ( getBarState() == BARSTATE_ALLBARS ){
    // ----------------------------------------

    var nDateM, nBarIndexM;


    // ----------------------------------------
    return null;
    } // END ALLBARS
    // ========================================


    ...
    ...

    // ****************************************
    if ( getBarState() == BARSTATE_NEWBAR ){
    // ----------------------------------------


    if (isDaily() == true){

    nDateM = new Date(getYear(0), 8, 30);

    if ( nDateM != null ) {
    nBarIndexM = getFirstBarIndexOfDay( nDateM );
    if ( nBarIndexM != null ) {

    //grab the closing price from that bar
    nQtr3m = close( nBarIndexM );

    }
    }

    drawLineRelative( nBarIndexM, nQtr3m, -0, nQtr3m, sQtrStyM, nQtrThkP, cAnnCurUpP, "qtr3B" );

    }else{

    nQtr3m = getValueAbsolute( "Close", -0+(9-nMthCurM), sMthSymG );
    addBand(nQtr3m, sQtrStyM, nQtrThkP, cAnnCurUpP, "qtr3B");
    }

    // ----------------------------------------
    } // end Newbar
    // ========================================





    Robert
    Last edited by rcameron; 06-01-2005, 03:51 AM.

  • #2
    I forgot to add the efs file, attached AnnQtrPiv.efs (V 1.0.0)

    Robert
    Attached Files

    Comment


    • #3
      Robert,

      I have one that I am using that has been working pretty well for me. I save the bar time of the start and end points in miliseconds, at present I am saving 2 records or points per "set", but built in the capability of up to 10 records per "set". Then I save the info in a file as a single line for each record "set". Then upon efs re-load, I align the data from the file onto the chart timeframe and replot. If the datpoint is outside the chart range, I set a variable to "F" and the set is not plotted. Alternatively, if it is in th erange of the chart, I set the variable to "T" and it is included. The code I am writing is not complete, but the section I am referencing has been working well for several weeks.

      Presently, I cannot get a simplified version running and posted. Posting a bulletproof version of what I am running is also not practical. However, I can post the sections that address most of what you want to do. Specifically, the DataConversion function is where I perform the merging of the file data with the chart. Again, this will not work as-is, but it may give you some ideas. Let me know if this works for you and is of some help.

      Regards,
      Attached Files

      Comment

      Working...
      X