Announcement

Collapse
No announcement yet.

New Trading Day Marker !!

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

  • New Trading Day Marker !!

    can someone make this a paint bar (not a line ) ?

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("New Trading Day Marker");
    setShowCursorLabel(false);

    var fp = new Array(3);
    fp[0] = new FunctionParameter("nHr", FunctionParameter.STRING);
    fp[1] = new FunctionParameter("nMin", FunctionParameter.STRING);
    fp[2] = new FunctionParameter("nSec", FunctionParameter.STRING);

    for (j = 0; j < 3; ++j) {
    for (i = 0; i < 60; ++i) {
    var num = i+"";
    if (i < 10) num = "0"+i;
    if (i < 24 && j == 0) {
    fp[j].addOption(num);
    } else {
    fp[j].addOption(num);
    }
    }
    }

    fp[0].setName("Set Hour");
    fp[1].setName("Set Minute");
    fp[2].setName("Set Second");

    fp[0].setDefault("09");
    fp[1].setDefault("30");
    fp[2].setDefault("00");
    }

    var vHr = null;
    var vMin = null;
    var vSec = null;
    var newDay = true;
    var dayCntr = 0;

    function main(nHr, nMin, nSec) {
    var nState = getBarState();
    var vInt = getInterval();
    if (vInt == "D" || vInt == "W" || vInt == "M") return;

    if (nState == BARSTATE_NEWBAR) {
    if (newDay == false && getDay() != getDay(-1) && getDay(-1) != null) newDay = true;
    if (newDay == true) {
    var barHr = getHour()+"";
    if (barHr != null && barHr < 10) barHr = "0"+barHr;
    var barMin = getMinute()+"";
    if (barMin != null && barMin < 10) barMin = "0"+barMin;
    var barSec = getSecond()+"";
    if (barSec != null && barSec < 10) barSec = "0"+barSec;
    if(barHr >= nHr && barMin >= nMin && barSec >= nSec) {
    drawLineRelative(0,0,0,99999,PS_SOLID, 1, Color.lightgrey, "NewDay"+dayCntr);
    //drawShapeRelative(0, 5, Shape.DIAMOND, null, Color.blue,
    //Shape.RELATIVETOBOTTOM, "NewDay"+dayCntr);
    dayCntr += 1;
    newDay = false;
    }
    }
    }

    return;
    }

  • #2
    PHP Code:
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("New Trading Day Marker");
    setShowCursorLabel(false);

    var 
    fp = new Array(3);
    fp[0] = new FunctionParameter("nHr"FunctionParameter.STRING);
    fp[1] = new FunctionParameter("nMin"FunctionParameter.STRING);
    fp[2] = new FunctionParameter("nSec"FunctionParameter.STRING);

    for (
    03; ++j) {
    for (
    060; ++i) {
    var 
    num i+"";
    if (
    10num "0"+i;
    if (
    24 && == 0) {
    fp[j].addOption(num);
    } else {
    fp[j].addOption(num);
    }
    }
    }

    fp[0].setName("Set Hour");
    fp[1].setName("Set Minute");
    fp[2].setName("Set Second");

    fp[0].setDefault("09");
    fp[1].setDefault("30");
    fp[2].setDefault("00");
    }

    var 
    vHr null;
    var 
    vMin null;
    var 
    vSec null;
    var 
    newDay true;
    var 
    dayCntr 0;

    function 
    main(nHrnMinnSec) {
    var 
    nState getBarState();
    var 
    vInt getInterval();
    if (
    vInt == "D" || vInt == "W" || vInt == "M") return;

    if (
    nState == BARSTATE_NEWBAR) {
    if (
    newDay == false && getDay() != getDay(-1) && getDay(-1) != nullnewDay true;
    if (
    newDay == true) {
    var 
    barHr getHour()+"";
    if (
    barHr != null && barHr 10barHr "0"+barHr;
    var 
    barMin getMinute()+"";
    if (
    barMin != null && barMin 10barMin "0"+barMin;
    var 
    barSec getSecond()+"";
    if (
    barSec != null && barSec 10barSec "0"+barSec;
    if(
    barHr >= nHr && barMin >= nMin && barSec >= nSec) {
             
    drawShapeRelative(020Shape.SQUAREnullColor.maroonShape.RELATIVETOBOTTOM"NewDay"+dayCntr

    dayCntr 
    += 1;
    newDay false;
    }
    }
    }

    return;

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      thanks but this does not paint the bar !!

      Comment


      • #4
        Re: New Trading Day Marker !!

        goforit20
        Here is what you need to do to paint the price bars.
        In your script comment out the following line of code (to comment out a line of code add // at the beginning of that line)
        PHP Code:
        drawLineRelative(0,0,0,99999,PS_SOLID1Color.lightgrey"NewDay"+dayCntr); 
        then in the line just above or below it add the following line of code
        PHP Code:
        setPriceBarColor(Color.blue); 
        changing the color with one of your choice
        At that point add the following two lines of code in the preMain function
        PHP Code:
        setColorPriceBars(true);
        setDefaultPriceBarColor(Color.black); 
        replacing the color with the default color you want to apply to the [other] bars.
        These two lines of code are always required in preMain when painting the price bars.
        Alex


        Originally posted by goforit20
        can someone make this a paint bar (not a line ) ?

        function preMain() {
        setPriceStudy(true);
        setStudyTitle("New Trading Day Marker");
        setShowCursorLabel(false);

        var fp = new Array(3);
        fp[0] = new FunctionParameter("nHr", FunctionParameter.STRING);
        fp[1] = new FunctionParameter("nMin", FunctionParameter.STRING);
        fp[2] = new FunctionParameter("nSec", FunctionParameter.STRING);

        for (j = 0; j < 3; ++j) {
        for (i = 0; i < 60; ++i) {
        var num = i+"";
        if (i < 10) num = "0"+i;
        if (i < 24 && j == 0) {
        fp[j].addOption(num);
        } else {
        fp[j].addOption(num);
        }
        }
        }

        fp[0].setName("Set Hour");
        fp[1].setName("Set Minute");
        fp[2].setName("Set Second");

        fp[0].setDefault("09");
        fp[1].setDefault("30");
        fp[2].setDefault("00");
        }

        var vHr = null;
        var vMin = null;
        var vSec = null;
        var newDay = true;
        var dayCntr = 0;

        function main(nHr, nMin, nSec) {
        var nState = getBarState();
        var vInt = getInterval();
        if (vInt == "D" || vInt == "W" || vInt == "M") return;

        if (nState == BARSTATE_NEWBAR) {
        if (newDay == false && getDay() != getDay(-1) && getDay(-1) != null) newDay = true;
        if (newDay == true) {
        var barHr = getHour()+"";
        if (barHr != null && barHr < 10) barHr = "0"+barHr;
        var barMin = getMinute()+"";
        if (barMin != null && barMin < 10) barMin = "0"+barMin;
        var barSec = getSecond()+"";
        if (barSec != null && barSec < 10) barSec = "0"+barSec;
        if(barHr >= nHr && barMin >= nMin && barSec >= nSec) {
        drawLineRelative(0,0,0,99999,PS_SOLID, 1, Color.lightgrey, "NewDay"+dayCntr);
        //drawShapeRelative(0, 5, Shape.DIAMOND, null, Color.blue,
        //Shape.RELATIVETOBOTTOM, "NewDay"+dayCntr);
        dayCntr += 1;
        newDay = false;
        }
        }
        }

        return;
        }

        Comment


        • #5
          no thats not it ?

          Comment


          • #6
            goforit20
            What exactly are you trying to paint?
            If you want to paint the price bars then the solution I suggested will work. If it does not then post the efs as you have modified it and someone will assist you in fixing it.
            Alex


            Originally posted by goforit20
            no thats not it ?

            Comment


            • #7
              i think i have it ......how do you not change all the other bars colors (keep them the normal red and green) ?

              Comment


              • #8
                goforit20
                See this post in reply to a similar question
                Alex


                Originally posted by goforit20
                i think i have it ......how do you not change all the other bars colors (keep them the normal red and green) ?

                Comment


                • #9
                  What exactly are you trying to paint?

                  ???
                  you have to load my code that i posted to see what i am talking about ........i see you did not do that and you are just guessing at what i am trying to do !..............if you load my code on a chart you will see that it draws a line at the 9:30 bar .........well i want to paint that bar and not have a line going thought it .........thats all !

                  Comment


                  • #10
                    goforit20
                    The modifications that I suggested earlier will do what you are trying to accomplish
                    Alex


                    Originally posted by goforit20
                    What exactly are you trying to paint?

                    ???
                    you have to load my code that i posted to see what i am talking about ........i see you did not do that and you are just guessing at what i am trying to do !..............if you load my code on a chart you will see that it draws a line at the 9:30 bar .........well i want to paint that bar and not have a line going thought it .........thats all !

                    Comment


                    • #11
                      Originally posted by goforit20
                      What exactly are you trying to paint?

                      ???
                      you have to load my code that i posted to see what i am talking about ........i see you did not do that and you are just guessing at what i am trying to do !..............if you load my code on a chart you will see that it draws a line at the 9:30 bar .........well i want to paint that bar and not have a line going thought it .........thats all !
                      I think that people are actually trying to help you of their own free will so you may want to lighten up.

                      If your problem is that the line covers your candlestick you could also try this (with acknowledgement to Alex)

                      Code:
                      
                      // Marks a line at 9.30
                      
                      function preMain()  {
                      
                          setPriceStudy(true);
                          setStudyTitle("930");
                          setComputeOnClose();
                      
                                          }
                      
                      function main() {
                      
                      
                      if((hour(0) * 100) + minute(0) == 930){
                             
                              var y1 = (low(0)-.03);
                              var y2 = (high(0)+.03);
                      //        var nOpen = (open(0)*.975);
                      
                              drawLineRelative(0, 0, 0,y1, PS_SOLID, 1, Color.white , 122);
                              drawLineRelative(0, y2 , 0, Infinity, PS_SOLID, 1, Color.white , 123);
                              drawTextRelative(-2,y1,"9.30",Color.white,null,"Arial",6,9,124);
                      
                      }
                      
                      
                      }

                      Comment

                      Working...
                      X