Announcement

Collapse
No announcement yet.

inv("D")

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

  • inv("D")

    when using inv("D") to retrieve the daily OHLC data on intraday charts, it seems the cutoff time is always set to 0:00, that is for all bars between 16:30 and midnight on ES, the value returned by high(-1, inv("D")) actually is the high of two trading days before because officially the bars after 16:30 should belong to the next trading day. So strictly speaking, it seems inv() is not implemented flawlessly.


    function preMain()
    {
    setPriceStudy(true);
    setComputeOnClose();
    setStudyTitle("TestDailyOnIntradayChart");
    }


    var barState;

    var returnArray;
    var dailyHighStudy, dailyLowStudy, dailyCloseStudy, dailyDayStudy;
    function main()
    {
    barState = getBarState();
    if ( barState == BARSTATE_ALLBARS ) {
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.yellow, 2);
    setDefaultBarFgColor(Color.red, 3);
    setDefaultBarFgColor(Color.red, 4);
    setPlotType(PLOTTYPE_FLATLINES, 0);
    setPlotType(PLOTTYPE_FLATLINES, 1);
    setPlotType(PLOTTYPE_FLATLINES, 2);
    setPlotType(PLOTTYPE_FLATLINES, 3);
    setPlotType(PLOTTYPE_FLATLINES, 4);
    returnArray = new Array(5);

    dailyHighStudy = high(inv("D"));
    dailyLowStudy = low(inv("D"));
    dailyCloseStudy = close(inv("D"));
    dailyDayStudy = day(inv("D"));

    returnArray[0] = dailyHighStudy.getValue(-1);
    returnArray[1] = dailyLowStudy.getValue(-1);
    returnArray[2] = dailyCloseStudy.getValue(-1);
    //returnArray[3] = dailyHighStudy.getValue(-2);
    //returnArray[4] = dailyLowStudy.getValue(-2);
    // returnArray[3] = high(0, inv("D"));
    // returnArray[4] = low(0, inv("D"));
    }
    else {
    returnArray[0] = dailyHighStudy.getValue(-1);
    returnArray[1] = dailyLowStudy.getValue(-1);
    returnArray[2] = dailyCloseStudy.getValue(-1);
    //returnArray[3] = dailyHighStudy.getValue(-2);
    //returnArray[4] = dailyLowStudy.getValue(-2);
    // returnArray[3] = high(0, inv("D"));
    // returnArray[4] = low(0, inv("D"));
    }


    return returnArray;

    }
    Last edited by clearpicks; 08-27-2009, 07:35 AM.
Working...
X