Announcement

Collapse
No announcement yet.

Time Marker

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

  • Time Marker

    Good Morning,

    I use "Time Marker" on minute charts to draw vertical lines corresponding to user defined time increments and it works very well. I would like to modify this routine to operate on tick charts and draw the same type of vertical lines on the times selected by and plotted by the tick chart at the bottom of the chart. These times are the same number of ticks between plotted times but are frequently a different absolute amount of time. I have not been able to get any modificatons to work correctly. Could someone offer assistance please?

    Best Regards,

    Alan

  • #2
    Alan
    Not sure as to which efs you are referring. If it is the Time Marker.efs I wrote (available here) then it should already work with tick charts as is. The only thing you will need to do is set a unique condition so as to prevent the lines/text to be drawn on every bar that falls in the specified time stamp.
    One way to do this would be to preceed the command to draw the line (or the text) with if(minute(0)!=minute(-1))
    Alex

    Comment


    • #3
      Alex,

      Thank you for your assistance. Looking at the preceeding chart, the vertical lines are drawn at uniform 5 minute time intervals with a variable number of ticks between the vertical lines. I would like to draw the vertical lines corresponding to the bottom times such as 12:55:18, 13:04:15, 13:10:17, etc on the preceeding chart (what ever the uniformly spaced chart defined times turn out to be) which means the vertical lines have a fixed number of ticks between them (uniform x axis spacing) and a variable amount of time between the vertical lines.

      Your assistance is greatly appreciated.

      Best Regards,

      Alan

      Comment


      • #4
        Alan
        Then all you need is just a bar counter (in the image posted earlier those time stamps are spaced every ten bars).
        Create a global variable called Counter and set it to 1. Then in main at every BARSTATE_NEWBAR you check if the Counter is less than 10 in which case you increment the Counter by 1 else you reset the Count to 1.
        Then outside of the NEWBAR condition check if the Counter is equal to 10 in which case you draw the line.
        While the lines will be evenly spaced I cannot guarantee though that they will fall exactly on the time markers (as these depend on where the very first one is placed)
        Alex

        Comment


        • #5
          time Marker

          Alex,

          Thank you for the suggestions. I tried to implement your ideas and now I receive an Apacche Tomcat errorr message when using the following script. I changed the version number to 7.9, the time to 5 minutes and added the code you suggested before the draw commands. Your help in debugging this script is appreciated.

          Best regards,

          Alan

          /************************************************** *******
          Alexis C. Montenegro © March 2004
          Use and/or modify this code freely. If you redistribute it
          please include this and/or any other comment blocks and a
          description of any changes you make.
          ************************************************** ********/

          function preMain() {
          setPriceStudy(false);
          setStudyTitle("Time Marker1fause");
          setCursorLabelName("Time");
          setShowTitleParameters(false);
          checkVersion(7.9,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/Time Marker.efs");

          var fp1 = new FunctionParameter("Interval", FunctionParameter.NUMBER);
          fp1.setLowerLimit(0);
          fp1.setDefault(5); //Edit this value to set a new default

          var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
          fp2.setDefault(0); //Edit this value to set a new default

          var fp3 = new FunctionParameter("Lines", FunctionParameter.STRING);
          fp3.addOption("On");
          fp3.addOption("Off");
          fp3.setDefault("On"); //Edit this value to set a new default

          var fp3a = new FunctionParameter("Time", FunctionParameter.STRING);
          fp3a.addOption("On");
          fp3a.addOption("Off");
          fp3a.setDefault("On"); //Edit this value to set a new default

          var fp4 = new FunctionParameter("Cursor", FunctionParameter.STRING);
          fp4.addOption("false");
          fp4.addOption("true");
          fp4.setDefault("true"); //Edit this value to set a new default

          }

          var Cntr = 0;
          var x;
          var y;
          var z;

          function main(Interval,Offset,Lines,Time,Cursor){

          setShowCursorLabel(eval(Cursor));

          if(isDWM()==true){
          setShowCursorLabel(false);
          return;
          }

          if(getBarState()==BARSTATE_NEWBAR){
          Cntr += 1;
          }

          x = (getHour()*1)+Offset;
          y = getMinute()*1;

          if(x>=24) x = x-24;
          if(x<0) x = 24+x;
          if(x<10) x = "0"+x;
          if(y<10) y = "0"+y;

          z = x+":"+y;

          if((getMinute()/Interval) == Math.floor(getMinute()/Interval)){
          if(Time=="On"){
          if(minute(0)!=minute(-1))
          drawTextRelative(0,0,z,Color.grey,null,Text.RELATI VETOBOTTOM,"Arial",10,"Time2"+Cntr);
          }
          if(Lines=="On"){
          if(minute(0)!=minute(-1))
          drawLineRelative(0,-20,0,99999,PS_SOLID, 1, Color.lightgrey,"Time"+Cntr);
          }
          }


          return z+"";
          }

          Comment


          • #6
            Alan
            Comment out or delete the line in preMain with checkVersion() and that will take care of the error you are seeing.
            BTW the checkVersion() command is not related to the version of eSignal but indicates the version of the efs for use with EFS Auto Update function
            Alex

            Comment


            • #7
              TimeMarker

              Alex,

              Thank you for the clarification. It is runnig properly now. I will try to get the tick based lines operating tommorrow.

              Best Regards,

              Alan

              Comment


              • #8
                Alan
                You are most welcome.
                BTW I just uploaded to my FileShare group a slightly revised version of Time Marker.efs which is modified to be a bit more efficient. All calculations are now inside the NEWBAR condition since they do not need to be executed on every tick.
                Alex

                Comment


                • #9
                  Alex,

                  Can you please run your eye over this? I've adapted your original code to drawn vertical lines four minutes apart on a tick chart but occassionally a line is skipped with eight minutes between lines. Why?

                  Cheers, Al.

                  /************************************************** *******
                  Alexis C. Montenegro © March 2004
                  Use and/or modify this code freely. If you redistribute it
                  please include this and/or any other comment blocks and a
                  description of any changes you make.
                  ************************************************** ********/

                  var fpArray = new Array();

                  function preMain() {
                  setPriceStudy(true);
                  setStudyTitle("Time Marker_AR ticks");
                  setCursorLabelName("Time");
                  setShowTitleParameters(false);
                  checkVersion(8,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/Time Marker.efs","Time Marker.efs");

                  var x=0;
                  fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
                  with(fpArray[x++]){
                  setLowerLimit(0);
                  setDefault(30);
                  }
                  fpArray[x] = new FunctionParameter("Offset", FunctionParameter.NUMBER);
                  with(fpArray[x++]){
                  setDefault(0);
                  }
                  fpArray[x] = new FunctionParameter("Lines", FunctionParameter.STRING);
                  with(fpArray[x++]){
                  addOption("On");
                  addOption("Off");
                  setDefault("Off");
                  }
                  fpArray[x] = new FunctionParameter("Time", FunctionParameter.STRING);
                  with(fpArray[x++]){
                  addOption("On");
                  addOption("Off");
                  setDefault("On");
                  }
                  fpArray[x] = new FunctionParameter("Cursor", FunctionParameter.STRING);
                  with(fpArray[x++]){
                  addOption("false");
                  addOption("true");
                  setDefault("true");
                  }
                  }

                  var bInit = false;
                  var Cntr = 0;
                  var x;
                  var y;
                  var z;

                  function main(Interval,Offset,Lines,Time,Cursor){


                  if(bInit==false){
                  if(isDWM()==true){
                  setShowCursorLabel(false);
                  return;
                  }else{
                  setShowCursorLabel(eval(Cursor));
                  }
                  }

                  if(getBarState()==BARSTATE_NEWBAR){
                  Cntr += 1;
                  x = (getHour()*1)+Offset;
                  y = getMinute()*1;
                  if(x >= 24) x = x-24;
                  if(x < 0) x = 24+x;
                  if(x < 10) x = "0"+x;
                  if(y < 10) y = "0"+y;
                  z = x+":"+y;

                  if((getMinute()/Interval) == Math.floor(getMinute()/Interval)){
                  if(Time=="On"){
                  if(minute(0)!=minute(-1))
                  drawTextRelative(0,0,z,Color.blue,null,Text.RELATI VETOBOTTOM,"Arial",10,"Time2"+Cntr);
                  }

                  if(Lines=="On"){
                  if(minute(0)!=minute(-1))
                  drawLineRelative(0,0,0,Infinity*1,PS_SOLID, 1, Color.blue,"Time"+Cntr);
                  }
                  }
                  }

                  return z+"";
                  }

                  Comment


                  • #10
                    Al
                    That will happen if there is no bar with a time stamp in which the minutes are evenly divisible by the interval you set
                    Alex

                    Comment


                    • #11
                      Ok, many thanks. Makes sense. I just needed to check in case I got some of the EFS code wrong.

                      Cheers, Al.

                      Comment


                      • #12
                        Al
                        You are most welcome
                        Alex

                        Comment

                        Working...
                        X