Announcement

Collapse
No announcement yet.

Draw line at the high of the first 15 minutes

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

  • Draw line at the high of the first 15 minutes

    I have been working on an EFS to automatically draw my Fib retracements and extentions. I have a successful EFS and will post it below, but I am having trouble with something.

    Right now, the EFS will draw lines based on the previous days high and low. However, if the current day open is above the previous day high, I want the high of the first 15 minute candle to act as yesterday's high in the calculation of the fib lines. So, in this instance, it would draw fib lines from the previous day low to the opening range high (15 min candle).

    I also want to do the opposite. If the open is lower than the previous day low, draw fib lines from the previous day high to the opening range low (15 min candle).

    I am trying to make this so that I can just scroll through a bunch of charts and it will already draw it for me based on these conditions. This way it won't matter if today's open is within yesterday's range or gap up or down, it just automatically draws it.

    I am a third of the way there and any help or guidance is greatly appreciated.

    Thanks,
    Tyler

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Auto Fib");
    setCursorLabelName("Prev High 2", 0);
    setCursorLabelName("Prev High 1.618", 1);
    setCursorLabelName("Prev High 1.5", 2);
    setCursorLabelName("Prev High 1.382", 3);
    setCursorLabelName("Prev High", 4);
    setCursorLabelName("Fib .618", 5);
    setCursorLabelName("Fib .5", 6);
    setCursorLabelName("Fib .382", 7);
    setCursorLabelName("Prev Low", 8);
    setCursorLabelName("Prev Low 1.382", 9);
    setCursorLabelName("Prev Low 1.5", 10);
    setCursorLabelName("Prev Low 1.618", 11);
    setCursorLabelName("Prev Low 2", 12);
    // Prev High 2
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev High 1.618
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev High 1.5
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev High 1.382
    setDefaultBarStyle(PS_SOLID, 3);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev High
    setDefaultBarStyle(PS_DASH, 4);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Fib .618
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Fib .5
    setDefaultBarStyle(PS_SOLID, 6);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Fib .382
    setDefaultBarStyle(PS_SOLID, 7);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev Low
    setDefaultBarStyle(PS_DASH, 8);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev Low 1.382
    setDefaultBarStyle(PS_SOLID, 9);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev Low 1.5
    setDefaultBarStyle(PS_SOLID, 10);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev Low 1.618
    setDefaultBarStyle(PS_SOLID, 11);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    // Prev Low 2
    setDefaultBarStyle(PS_SOLID, 12);
    setDefaultBarFgColor(Color.blue);
    setDefaultBarThickness(1);
    setPlotType(PLOTTYPE_FLATLINES);
    }

    var bInit = false;
    var xHigh = null;
    var xLow = null;
    var vPH0 = null;
    var vPH1 = null;
    var vPH2 = null;
    var vPH3 = null;
    var vPH4 = null;
    var vPH5 = null;
    var vPH6 = null;
    var vPH7 = null;
    var vPH8 = null;
    var vPH9 = null;
    var vPH10 = null;
    var vPH11 = null;
    var vPH12 = null;


    function main() {

    if(isMonthly() || isWeekly() || isDaily())
    return;

    if(bInit == false){
    xHigh = high(inv("D"));
    xLow = low(inv("D"));
    bInit = true;
    }

    var vHigh = xHigh.getValue(-1);
    var vLow = xLow.getValue(-1);
    if(vHigh == null || vLow == null)
    return;

    vPH0 = (xHigh.getValue(-1)-xLow.getValue(-1))*1+xHigh.getValue(-1);
    vPH1 = (xHigh.getValue(-1)-xLow.getValue(-1))*.618+xHigh.getValue(-1);
    vPH2 = (xHigh.getValue(-1)-xLow.getValue(-1))*.5+xHigh.getValue(-1);
    vPH3 = (xHigh.getValue(-1)-xLow.getValue(-1))*.382+xHigh.getValue(-1);
    vPH4 = xHigh.getValue(-1);
    vPH5 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.618);
    vPH6 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.5);
    vPH7 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.382);
    vPH8 = xLow.getValue(-1);
    vPH9 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.382);
    vPH10 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.5);
    vPH11 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.618);
    vPH12 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*1);

    return new Array(vPH0, vPH1, vPH2, vPH3, vPH4, vPH5, vPH6, vPH7, vPH8, vPH9, vPH10, vPH11, vPH12);
    }
    Attached Files

  • #2
    Draw line at the high of the first 15 minutes

    Does anyone know the code to draw a line at the high of the first 15 minutes of the day?

    All I can do is draw lines on different bars in relation to the current bar, so my line is constantly changing. I need a fixed value.

    Thanks,
    Tyler

    Comment


    • #3
      TS

      This would be a GOOD PLACE TO START

      http://forum.esignalcentral.com/show...rst+30+minutes

      Comment


      • #4
        dloomis,

        Thanks for the direction. I think there might be an easier way to change the code I already have, but still can't figure it out. Please let me know what you think.

        Currently it is set to use the previous day low and previous day high in the calculation, but instead of the previous day high I want to use the high of the first 15 minutes of today.

        If anyone can help I would appreciate it.

        Thanks,
        Tyler

        function preMain() {
        setPriceStudy(true);
        setStudyTitle("Auto Fib");
        setCursorLabelName("Prev High 2", 0);
        setCursorLabelName("Prev High 1.618", 1);
        setCursorLabelName("Prev High 1.5", 2);
        setCursorLabelName("Prev High 1.382", 3);
        setCursorLabelName("Prev High", 4);
        setCursorLabelName("Fib .618", 5);
        setCursorLabelName("Fib .5", 6);
        setCursorLabelName("Fib .382", 7);
        setCursorLabelName("Prev Low", 8);
        setCursorLabelName("Prev Low 1.382", 9);
        setCursorLabelName("Prev Low 1.5", 10);
        setCursorLabelName("Prev Low 1.618", 11);
        setCursorLabelName("Prev Low 2", 12);
        // Prev High 2
        setDefaultBarStyle(PS_SOLID, 0);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev High 1.618
        setDefaultBarStyle(PS_SOLID, 1);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev High 1.5
        setDefaultBarStyle(PS_SOLID, 2);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev High 1.382
        setDefaultBarStyle(PS_SOLID, 3);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev High
        setDefaultBarStyle(PS_DASH, 4);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Fib .618
        setDefaultBarStyle(PS_SOLID, 5);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Fib .5
        setDefaultBarStyle(PS_SOLID, 6);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Fib .382
        setDefaultBarStyle(PS_SOLID, 7);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev Low
        setDefaultBarStyle(PS_DASH, 8);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev Low 1.382
        setDefaultBarStyle(PS_SOLID, 9);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev Low 1.5
        setDefaultBarStyle(PS_SOLID, 10);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev Low 1.618
        setDefaultBarStyle(PS_SOLID, 11);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        // Prev Low 2
        setDefaultBarStyle(PS_SOLID, 12);
        setDefaultBarFgColor(Color.blue);
        setDefaultBarThickness(1);
        setPlotType(PLOTTYPE_FLATLINES);
        }

        var bInit = false;
        var xHigh = null;
        var xLow = null;
        var vPH0 = null;
        var vPH1 = null;
        var vPH2 = null;
        var vPH3 = null;
        var vPH4 = null;
        var vPH5 = null;
        var vPH6 = null;
        var vPH7 = null;
        var vPH8 = null;
        var vPH9 = null;
        var vPH10 = null;
        var vPH11 = null;
        var vPH12 = null;


        function main() {

        if(isMonthly() || isWeekly() || isDaily())
        return;

        if(bInit == false){
        xHigh = high(inv("D"));
        xLow = low(inv("D"));
        bInit = true;
        }

        var vHigh = xHigh.getValue(-1);
        var vLow = xLow.getValue(-1);
        if(vHigh == null || vLow == null)
        return;

        vPH0 = (xHigh.getValue(-1)-xLow.getValue(-1))*1+xHigh.getValue(-1);
        vPH1 = (xHigh.getValue(-1)-xLow.getValue(-1))*.618+xHigh.getValue(-1);
        vPH2 = (xHigh.getValue(-1)-xLow.getValue(-1))*.5+xHigh.getValue(-1);
        vPH3 = (xHigh.getValue(-1)-xLow.getValue(-1))*.382+xHigh.getValue(-1);
        vPH4 = xHigh.getValue(-1);
        vPH5 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.618);
        vPH6 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.5);
        vPH7 = xLow.getValue(-1)+((xHigh.getValue(-1)-xLow.getValue(-1))*.382);
        vPH8 = xLow.getValue(-1);
        vPH9 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.382);
        vPH10 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.5);
        vPH11 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*.618);
        vPH12 = xLow.getValue(-1)-((xHigh.getValue(-1)-xLow.getValue(-1))*1);

        return new Array(vPH0, vPH1, vPH2, vPH3, vPH4, vPH5, vPH6, vPH7, vPH8, vPH9, vPH10, vPH11, vPH12);
        }
        Attached Files

        Comment

        Working...
        X