Announcement

Collapse
No announcement yet.

getFirstBarIndexOfDay isn't sufficient.

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

  • getFirstBarIndexOfDay isn't sufficient.

    I have attached a picture to make what I am asking clearer. I would like the code below to draw the high and low of the current session (the starting times for the session obviously varies as I change the contract and market in the chart). At the moment this code draws the high and low from the start of the day (00:00) not the start of the session, which in this case was 16:30 (where the vertical cursor line intersects). If someone could show me how to modify this to draw from the start of the session I would be most appreciative.
    Thankyou so much.

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("THTLNCC");
    setCursorLabelName("TH",0);
    setDefaultBarFgColor(Color.RGB(128,0,128),0);
    setDefaultBarThickness(1,0);
    setPlotType(PLOTTYPE_FLATLINES,0);
    setCursorLabelName("TL",1);
    setDefaultBarFgColor(Color.RGB(128,0,128),1);
    setDefaultBarThickness(1,1);
    setPlotType(PLOTTYPE_FLATLINES,1);
    }

    var currentAddHigh = null;
    var currentAddLow = null;

    function main() {
    if(isMonthly() || isWeekly() || isDaily())
    return;
    nTime = getValue( "rawtime", 0 );
    if(getFirstBarIndexOfDay( nTime ) == getCurrentBarIndex()) {
    currentAddHigh = high(0);
    currentAddLow = low(0);
    }
    if(high(0) > currentAddHigh) {
    currentAddHigh = high(0);
    }
    if(low(0) < currentAddLow) {
    currentAddLow = low(0);
    }
    if(currentAddHigh != null) {
    return new Array(currentAddHigh,currentAddLow);
    }
    return;
    }
    Attached Files

  • #2
    You may try to search the forums. Many excellent scripts have been created by talented folks. The following efs which may do what you need or help you get there.



    That is found in a forum post (link follows) which has some other very useful scripts from Alexis Montenegro.



    Wayne

    Comment

    Working...
    X