Announcement

Collapse
No announcement yet.

Larry Williams concept: Trade day of week

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

  • Larry Williams concept: Trade day of week

    Trade day of week (TDW) is a concept Larry Williams describes in some of his books. Larry: "TDW can make a big difference in your system´s performance."

    In advance Larry suggests that day traders should do some research on Trading hours of day (THD). We know this: avoid day trading during lunch time.

    I think there should be a way to do this calculation in eSignal. Unfortunately I have no idea to do this job in efs. Is this a major exercise?

    The TDW-Code would be useful, to have a look what´s happening if we only take buys and sells on certain specific days (hours). Let´s give TDW- and TDH-Backtesting a try to get a closer look to the behaviour of our systems.

    One of my ideas is to calculate the average trading range (high(0)-low(0)) from the last 10 mondays, tuesdays ... Lets name this ATR (TDW)

    The formula looks like this:

    ( (high(MondayThisWeek)-low(MondayThisWeek)) + (high(MondayLastWeek)-low(MondayLastWeek )) + (high(MondayTwoWeeksbefore)-low(MondayTwoWeeksbefore)) + ...) /10

    Would be great to get support for this idea. Thanks!

  • #2
    Does this help:


    {
    9:50-10:10AM
    Often times, a stock that is moving up into this reversal time zone will
    either stall or reverse and head lower. The same is true for the reverse.
    This reversal time is by far one of the most reliable times in existence.

    10:25-10:35AM
    A stock that is moving down into this reversal time zone will also tend to
    either stall or reverse back to the upside. If a stock is moving up into
    this time zone, it will often halt its advance or reverse and head
    lower. This is also one of the more reliable reversal times.

    11:15-11:30AM
    This reversal time tends to accomplish two things. First, it tends to halt
    the prevailing trend preceding it. A stall that this time zone puts in,
    will tend to be an enduring one. This period also kicks off the period
    called the midday doldrums. This is an elongated period that spans

    11:15-2:15PM. During this extended time zone, many stocks, as well as the
    market as a whole, often go into a major lull.

    12:00-12:15PM
    This time period is most important on days in which the morning has been
    quiet or directionless. Despite the fact that it is the midday doldrums
    period, this time zone can kick off some major moves in both directions,
    but usually only when the preceding period was very quiet. This reversal
    period is far less common than the preceding three.

    1:15-1:30PM
    This is one of the more minor reversal periods. It is usually most
    significant when it coincides with the retest of a prior high or low. An
    example, XYZ tops out around 11:15AM and after a pullback, it rallies back
    to retest the 11:15AM high in the 1:15-1:30PM time period. The odds of a
    double top dramatically increase, because the retest of the prior high is
    coinciding with this time period and can present some interesting trading
    opportunities.

    2:15-2:30PM
    This time period puts an end to the midday doldrums and serves as a very
    reliable reversal period for stocks and the general market. This period
    often marks the precise period when things start heating up again. It is
    so pronounced at times that many regard the period as the market's second open.

    3:00PM
    This reversal time often brings change because it coincides with the close
    of the bond market. This often results in stocks or the market taking on a
    different, more accelerated character.

    3:30PM
    This time often reverses any move that was kicked off at the previous

    3:00PM reversal time, particularly when the market is in a sideways trading
    range. The last half hour is one of the most active for many day traders.

    4:00PM
    Once extended 24-hour trading takes place, look for this time to be an
    important reversal time.
    }

    Comment


    • #3
      My research targets another direction.

      Please take a look at this code and the attached chart. I am aware that this code is not really doing what I want.

      Maybe I should work whith an array, I suppose, but I have no idea, how to push specific days of week in an array to average only mondays, tuesdays ...


      PHP Code:
      function preMain() {
      setPriceStudy(false);
      setStudyTitle("Day of week");
      setShowCursorLabel(true);
      setPlotType(PLOTTYPE_HISTOGRAM0);
      setPlotType(PLOTTYPE_SQUAREWAVE1);
      setDefaultBarFgColor(Color.black1);
      setDefaultBarThickness(2,0);
      setCursorLabelName("AvgHSDayOfWeek"0);
      setCursorLabelName("HS Today"1);
      setStudyMin(0.2); 
      }


      function 
      main() {

          var 
      vDate getValue("Time");

          var 
      vDayOfWeek vDate.getDay();

          if      (
      vDayOfWeek == 1)   {setBarFgColor(Color.red);}    
          if      (
      vDayOfWeek == 2)   {setBarFgColor(Color.blue);}    
          if      (
      vDayOfWeek == 3)   {setBarFgColor(Color.green);}    
          if      (
      vDayOfWeek == 4)   {setBarFgColor(Color.black);}    
          if      (
      vDayOfWeek == 5)   {setBarFgColor(Color.aqua);}    
          
          var 
      high(0)  - low(0
          var 
      high(-5) - low(-5
          var 
      high(-10) - low(-10
          var 
      high(-15) - low(-15)
          var 
      high(-20) - low(-20)
          var 
      high(-25) - low(-25)
          var 
      high(-30) - low(-30
          var 
      high(-35) - low(-35
          var 
      high(-40) - low(-40
          var 
      high(-45) - low(-45
          var 
      high(-50) - low(-50
          
          var 
      AvgHSDayOfWeek = (A+B+C+D+E+F+G+H+I+J)/10
          
          
      return AvgHSDayOfWeek

      Attached Files

      Comment


      • #4
        Here you go.

        If you set iDebug = true, it will display the internals in the formula output window.

        HTH.

        P.S. IMHO, the histogram doesn't plot as nice as flatlines.



        PHP Code:
        /****************************

        $AvgPerWeekDay - PLOT AVERAGE PRICE FOR DAY OF WEEK


        **************/


        function preMain() {

        setPriceStudy(false);

        setStudyTitle("Avg per Day of week");

        setShowCursorLabel(true);

        setPlotType(PLOTTYPE_FLATLINES 0);

        setDefaultBarFgColor(Color.black1);

        setDefaultBarThickness(2,0);

        setCursorLabelName("AvgHSDayOfWeek"0);

        setCursorLabelName("HS Today"1);

        // setStudyMin(0.2); 

            
        var fp3 = new FunctionParameter("iSource"FunctionParameter.STRING);
            
        fp3.setName("Price Source");
            
        fp3.addOption("High");
            
        fp3.addOption("Low");
            
        fp3.addOption("Close");
            
        fp3.setDefault("High");

            var 
        iLineType = new FunctionParameter("iLineType"FunctionParameter.STRING);
                   
        iLineType.addOption("PLOTTYPE_HISTOGRAM");
                   
        iLineType.addOption("PLOTTYPE_SQUAREWAVE");
                   
        iLineType.addOption("PLOTTYPE_FLATLINES");
                   
        iLineType.addOption("PLOTTYPE_SQUARE");
                   
        iLineType.addOption("PLOTTYPE_CIRCLE");
                   
        iLineType.addOption("PLOTTYPE_INSTANTCOLORLINE");
                   
        iLineType.setDefault"PLOTTYPE_LINE" ); 

            var 
        iDebug = new FunctionParameter("iDebug"FunctionParameter.BOOLEAN);
            
        iDebug.setDefaultfalse );



            var 
        iButtonX = new FunctionParameter("iButtonX"FunctionParameter.NUMBER);
            
        iButtonX.setDefault); 

            var 
        iButtonY = new FunctionParameter("iButtonY"FunctionParameter.NUMBER);
            
        iButtonY.setDefault); 

            var 
        iFontSize = new FunctionParameter("iFontSize"FunctionParameter.NUMBER);
            
        iFontSize.setDefault10 ); 

        }

        var 
        c1 0;
        var 
        c2 0;
        var 
        c3 0;
        var 
        c4 0;
        var 
        c5 0;

        SumMon 0;
        SumTue 0;
        SumWed 0;
        SumThu 0;
        SumFri 0;

        AvgMonH 0;
        AvgTueH 0;
        AvgWedH 0;
        AvgThuH 0;
        AvgFriH 0

        var 
        AvgHSDayOfWeek 0;



           
        askForInput("TRO_NORMALIZER");


        function 
        mainiDebugiSourceiLineTypeiFontSizeiButtonXiButtonY ) {


            if(
        getBarState() == BARSTATE_ALLBARS) {
                
        drawTextPixeliButtonX iButtonY" AvgPerWeekDay @URL=EFS:editParameters"
                
        Color.whiteColor.lime
                
        Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON
                
        "Comic Sans MS"13"UpExp"); 
                
                
        iInterval getInterval();
           
                
        xSymbol getSymbol().toUpperCase();
                  
                  return 
        null;

            } 
        // getBarState


            
        var vDate getValue("Time");

            var 
        vDayOfWeek vDate.getDay();

            if (
        iSource == "Close") {
                var 
        close()
                var 
        p1 close(-1);
            } else if (
        iSource == "High") {
                var 
        high()
                var 
        p1 high(-1);
            } else if (
        iSource == "Low") {
                var 
        low()
                var 
        p1 low(-1);
            }
            
            if      (
        vDayOfWeek == 1)   {
                     
        setBarFgColor(Color.red);
                     
        c1 c1 1;
                     if( 
        c1 != 0) {
                       
        SumMon = ( SumMon ) ;
                       
        AvgMonH = ( SumMon ) / c1;
                       
        AvgHSDayOfWeek AvgMonH ;}
                     }    
            if      (
        vDayOfWeek == 2)   {
                     
        setBarFgColor(Color.blue);
                     
        c2 c2 1;
                     if( 
        c2 != 0) {
                       
        SumTue = ( SumTue )  ;
                       
        AvgTueH = ( SumTue  ) / c2;
                       
        AvgHSDayOfWeek AvgTueH ; }
                     }         
            if      (
        vDayOfWeek == 3)  {  
                     
        setBarFgColor(Color.green);
                     
        c3 c3 1;
                     if( 
        c3 != 0) {             
                       
        SumWed = ( SumWed )  ;
                       
        AvgWedH = ( SumWed  ) / c3;
                       
        AvgHSDayOfWeek AvgWedH ; }
                     }    
            if      (
        vDayOfWeek == 4)   {
                     
        setBarFgColor(Color.black);
                     
        c4 c4 1;
                     if( 
        c4 != 0) {
                     
        SumThu = ( SumThu  ) ; 
                     
        AvgThuH = ( SumThu   ) / c4
                     
        AvgHSDayOfWeek AvgThuH ; }
                     }    
            if      (
        vDayOfWeek == 5)   {
                     
        setBarFgColor(Color.aqua);
                     
        c5 c5 1;
                     if( 
        c5 != 0) {
                     
        SumFri = ( SumFri )  ;
                     
        AvgFriH = ( SumFri   ) / c5;
                     
        AvgHSDayOfWeek AvgFriH ; }
                     }    
            
            
        if(
        iDebug == true) { 
         
        // debugClear(); 

         


          
        debugPrint"                "   "\n" ); 
          
          
        debugPrint"c5            : " c5  "\n" );
          
        debugPrint"AvgFriH        : " AvgFriH  "\n" );

          
        debugPrint"c4            : " c4  "\n" );
          
        debugPrint"AvgThuH        : " AvgThuH  "\n" );

          
        debugPrint"c3            : " c3  "\n" );
          
        debugPrint"AvgWedH        : " AvgWedH  "\n" );

          
        debugPrint"c2            : " c2  "\n" );
          
        debugPrint"AvgTueH        : " AvgTueH  "\n" );

          
        debugPrint"c1            : " c1  "\n" );
          
        debugPrint"AvgMonH        : " AvgMonH  "\n" );

          
        debugPrint"iSource        : " iSource  "\n" );
          
          
        debugPrint"vDayOfWeek    : " vDayOfWeek  "\n" );

          
        debugPrint"Value         : " p  "\n" );
          
        debugPrint"Source        : " iSource  "\n" );
          
        debugPrint"--xSymbol     : " xSymbol  "\n" );

        debugPrint"getCurrentBarCount() : " getCurrentBarCount() +  "\n" );  
        debugPrint"-------------: " "\n" ); 

        // debug 

         
            
            
        return ( AvgHSDayOfWeek ) ;
        }



        //==rnd wiLL round to N digits.
        function rnd(valueN) {
            var 
        n;
            var 
        mult=1;
            for(
        n=0;n<N;n++) mult*=10;
            
        value*=mult;
            return 
        Math.roundvalue,N)/mult;
        }



        function 
        editParameters() {
            
        askForInput("AvgPerWeekDay");
            return;

        Attached Files

        Comment


        • #5
          @buzzhorton

          Thanks a lot! I´ll have to study your code and will be back.

          Comment


          • #6
            @buzzhorton

            I changed your code to get daily ranges, but unfortunately it does not work at my end. :-( Do you have an idea what´s wrong?

            PHP Code:
                if      (vDayOfWeek == 1)   {
                         
            setBarFgColor(Color.blue);
                         
                         
            c1 c1 1;
                         if( 
            c1 != && c1 5) {
                           
            SumMon = ( SumMon high()-low() ) ;
                           
            AvgMonH = ( SumMon ) / c1;
                           
            AvgHSDayOfWeek AvgMonH ;}
                         }    
                if      (
            vDayOfWeek == 2)   {
                         
            setBarFgColor(Color.red);
                         
            c2 c2 1;
                         if( 
            c2 != && c2 ) {
                           
            SumTue = ( SumTue high()-low() )  ;
                           
            AvgTueH = ( SumTue  ) / c2;
                           
            AvgHSDayOfWeek AvgTueH ; }
                         }         
                if      (
            vDayOfWeek == 3)  {  
                         
            setBarFgColor(Color.green);
                         
            c3 c3 1;
                         if( 
            c3 != && c3 5) {             
                           
            SumWed = ( SumWed high()-low() )  ;
                           
            AvgWedH = ( SumWed  ) / c3;
                           
            AvgHSDayOfWeek AvgWedH ; }
                         }    
                if      (
            vDayOfWeek == 4)   {
                         
            setBarFgColor(Color.black);
                         
            c4 c4 1;
                         if( 
            c4 != && c4 4) {
                         
            SumThu = ( SumThu  high()-low() ) ; 
                         
            AvgThuH = ( SumThu   ) / c4
                         
            AvgHSDayOfWeek AvgThuH ; }
                         }    
                if      (
            vDayOfWeek == && c5 5)   {
                         
            setBarFgColor(Color.aqua);
                         
            c5 c5 1;
                         if( 
            c5 != 0) {
                         
            SumFri = ( SumFri high()-low() )  ;
                         
            AvgFriH = ( SumFri   ) / c5;
                         
            AvgHSDayOfWeek AvgFriH ; }
                         } 
            Attached Files

            Comment


            • #7
              Q. Are you using this on a daily chart?

              Comment


              • #8
                Yes I do. see attached chart.
                Attached Files

                Comment


                • #9
                  I am just wondering, why this code does not monitor a moving average of the Monday-Range.

                  Spended multiple hours, tried different ways, but I am not capable of solving this. Please help!

                  PHP Code:
                      var vDate getValue("Time");
                      var 
                  vDayOfWeek vDate.getDay();

                      if      (
                  vDayOfWeek == 1)   {
                              
                  setPriceBarColor(Color.blue);
                              
                              var 
                  HSMon high(0)-low(0);
                              var 
                  UpMon high(0)-open(0);
                              var 
                  DnMon low(0)-open(0);
                              var 
                  DiffMon UpMon DnMon;
                              
                              
                  MAHSMon sma(25HSMon   );

                  ...

                  return 
                  MAHSMon
                  Attached Files

                  Comment


                  • #10
                    "... Driving you mad. Like a splinter in your mind..."

                    "I know exactly how you feel."

                    Ever see THE MATRIX?

                    Anyway, I think what you might have to do is create series somehow or load an array and push the values through as it goes along and then average the array.

                    Comment


                    • #11
                      It´s crucial to get more knowledge about arrays, but the support from eSignal in this case is unsatisfactory.

                      Studied video training, crawled the board...

                      A friend coded this indicator in EasyLanguage. Nomen est omen!


                      Indicator: Fr_Avg


                      *****************************
                      Variables: j(0),
                      average(0);

                      Array: Fridayranges[5](0);

                      if dayofweek(date) = 5 then begin

                      for j=4 downto 1 begin

                      Fridayranges[j] = Fridayranges[j-1];
                      end;
                      Fridayranges[0] = (high-low)/2;

                      end;

                      average = average_a(Fridayranges,5);

                      Plot1(average,"average",yellow);

                      ********************************

                      Comment

                      Working...
                      X