Announcement

Collapse
No announcement yet.

Dynamic S/R Zones

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic S/R Zones

    I'm trying to create an EFS that plots value based dynamic support / resistance zones. I am not able to do it in the wizard and that is my limit of programming ability.

    When I look at an OHLC chart it appears obvious that the more often a price Open, High, Low and Close is the same over a given period, the more likely it is that that price will act as s/r.

    By assigning a value of 1 to O, H and L and 2 to C, the sum of the values at the prices over a given period could identify the top 3 (or more) to define the range of a zone.

    If input = period of long (red), intermediate (blue) and short (green) and zones changed only when some criteria met then this indicator could be very helpful to identify strong S/R zones.

    I hope this makes sense and someone with the skill to develop this idea of value based dynamic S/R zones will contact me.
    OpaBert

  • #2
    I just converted my Dynamic S/R indicator from TradeStation to eSignal.

    If you change the iPeriods, you change the sensitivity of the indicator. I find that 5 works well for all time periods.

    MAY ALL YOUR FILLS BE COMPLETE.

    PHP Code:


    /*********************************************************
    TRO_DYNAMIC_SR 20060722 PLOT DYNAMIC SUPPORT/RESISTANCE


    Programmer:  Avery T. Horton, Jr.  aka *************, 
     


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

    debugClear(); 

    function 
    preMain() {

        
    setPriceStudy(true);
        
    setStudyTitle("TRO_DYNAMIC_SR");

        
    setCursorLabelName("Dyn_R"0);
     
        
    setCursorLabelName("Dyn_S"1);

        
    setDefaultBarFgColor(Color.red,0);

        
    setDefaultBarFgColor(Color.blue,1);

        
    setDefaultBarThickness(4,0); 
        
    setDefaultBarThickness(4,1); 

        
    setPlotType(PLOTTYPE_SQUARE ,0);
        
    setPlotType(PLOTTYPE_SQUARE ,1); 


     
    }

    var 
    Dynamic_R             0;
    var 
    Dynamic_S             0;
    var 
    OldDynamic_R     0;
    var 
    OldDynamic_S     0;
    var 
    PrevDynamic_R     0;
    var 
    PrevDynamic_S     0;   

    askForInput();


        var 
    iAlert = new FunctionParameter("iAlert"FunctionParameter.BOOLEAN);
        
    iAlert.setDefaulttrue );

        var 
    iPeriods = new FunctionParameter("iPeriods"FunctionParameter.NUMBER);
        
    iPeriods.setDefault05 );

    function 
    mainiAlert iPeriods ) {

        if (
    close(-1)==null
            return;
        
        if( 
    getBarState() == BARSTATE_NEWBAR && getDay() != getDay(-1) ) {
           var 
    Dynamic_R =    high() ;  // dynamic Resistance
           
    var Dynamic_S =    low() ;  // dynamic Suport
        
    }


    if ( 
    Dynamic_R != PrevDynamic_R ) {
        
    OldDynamic_R PrevDynamic_R 
        }
            
    if ( 
    Dynamic_S != PrevDynamic_S ) {
        
    OldDynamic_S  PrevDynamic_S 
        }
        
    OldDynamic_R PrevDynamic_R ;
    OldDynamic_S PrevDynamic_S ;

    PrevDynamic_R Dynamic_R ;
    PrevDynamic_S Dynamic_S ;



    Dynamic_R =   highestiPeriods high() ) ;  // dynamic Resistance
     
    Dynamic_S =   lowestiPeriods low() ) ;  // dynamic Suport

       
    if ( Dynamic_R != high(0) && Dynamic_R PrevDynamic_R ) {
         if ( 
    PrevDynamic_R != ) {
            
    Dynamic_R PrevDynamic_R;
             }
    }
        

    if ( 
    Dynamic_S != low(0) && Dynamic_S PrevDynamic_S ) {        
        if ( 
    PrevDynamic_S != ) {
            
    Dynamic_S PrevDynamic_S;
            }
    }

        
        
        if (
    Dynamic_R == null || Dynamic_S == null ) {
            return;
        } else {



    debugPrint"--------------------------------"    "\n" );

    debugPrint"DYNAMIC SUPPORT:    " formatPriceNumberDynamic_S )  + "\n" );
    debugPrint"LOW:                " formatPriceNumberlow(0) ) + "\n" ); 
    debugPrint"PrevDynamic_S:      " formatPriceNumberDynamic_S ) + "\n" );

    debugPrint"DYNAMIC RESISTANCE: " formatPriceNumberDynamic_R ) + "\n" ); 
    debugPrint"HIGH:               " formatPriceNumberhigh(0) )  + "\n" );
    debugPrint"PrevDynamic_R:      " formatPriceNumberDynamic_R ) +  "\n" ); 

    debugPrintgetValue"Time" )      + "\n" );
    debugPrint"------- TRO_DYNAMIC_SR ---------"    "\n" );

    //  ALERT 

        
    if(   close(0) >= Dynamic_R ){
        
    Alert.addToList(getSymbol(), Dynamic_R +" DYNAMIC RESISTANCE"Color.blueColor.black);
          if( 
    iAlert == true Alert.playSound("ding.wav");

          
    debugPrint("DYNAMIC RESISTANCE: " formatPriceNumberDynamic_R  ) + " " +  getValue"Time" ) + "\n" ); 
         }
     
        if(  
    close(0) <= Dynamic_S ){
        
    Alert.addToList(getSymbol(), Dynamic_S +" DYNAMIC SUPPORT"Color.redColor.black);
            if( 
    iAlert == true Alert.playSound("ding.wav");

          
    debugPrint("DYNAMIC SUPPORT: " formatPriceNumberDynamic_S ) + " " +  getValue"Time" ) + "\n" );  
         }


     if ( 
    isLastBarOnChart() == true ) { 
     
          
    //print a line of text to that window 
    //      debugPrint( "DYNAMIC SUPPORT:    " + formatPriceNumber( Dynamic_S  ) + "\n" ); 
    //      debugPrint( "DYNAMIC RESISTANCE: " + formatPriceNumber( Dynamic_R ) + "\n" ); 

    //     debugPrint( "iPeriods: " + formatPriceNumber( iPeriods ) + "\n" ); 
       



            return new Array( 
    Dynamic_R ,Dynamic_S  );
        }

    Attached Files
    Last edited by buzzhorton; 07-23-2006, 01:10 PM.

    Comment


    • #3
      It works slighty different that on TradeStation... have to figure out why..

      here's my TradeStation code:

      PHP Code:

      {save old values}
          
      If 
      Dynamic_R <> PrevDynamic_R
          then OldDynamic_R 
      PrevDynamic_R;
              
      If 
      Dynamic_S <> PrevDynamic_S 
          then OldDynamic_S  
      PrevDynamic_S ;
          
      OldDynamic_R PrevDynamic_R ;
      OldDynamic_S PrevDynamic_S ;

      PrevDynamic_R Dynamic_R ;
      PrevDynamic_S Dynamic_S ;

      PrevDynamic_UpVol    Dynamic_UpVol ;
      PrevDynamic_DnVol    Dynamic_DnVol ;


      high low for period }
          

      If 
      <> d[1]
          
      then xBars 0;

      xBars xBars 1;

      If 
      xBars xOldPeriods
      and iResetSR
      and xInterval 92
          then begin
              xPeriods 
      xBars ;            // start fresh each day
              
      PrevDynamic_S    ;
              
      PrevDynamic_R    ;
          
      end
          
      else begin
               xPeriods         
      xOldPeriods ;    // no reset 
          
      end;


      oExtremeVal ExtremesLxPeriods, -1Dynamic_S oExtremeBar ) ; // lowest low

      oExtremeVal ExtremesHxPeriods1Dynamic_R oExtremeBar ) ; // highest high

      xHH Dynamic_R ;
      xLL Dynamic_S ;


      Dynamic_UpVol UpTicks ;

      Dynamic_DnVol DownTicks ;


      If 
      Dynamic_R <> H
      and Dynamic_R PrevDynamic_R
          then 
      if PrevDynamic_R <> 0
              then Dynamic_R 
      PrevDynamic_R;
          
      If 
      Dynamic_S <> L
      and Dynamic_S PrevDynamic_S         
          then 
      if PrevDynamic_S <> 0
              then Dynamic_S 
      PrevDynamic_S
      debug output follows
      Attached Files

      Comment


      • #4
        Here's my eSignal code:

        PHP Code:



        if ( Dynamic_R != PrevDynamic_R ) {
            
        OldDynamic_R PrevDynamic_R 
            }
                
        if ( 
        Dynamic_S != PrevDynamic_S ) {
            
        OldDynamic_S  PrevDynamic_S 
            }
            
        OldDynamic_R PrevDynamic_R ;
        OldDynamic_S PrevDynamic_S ;

        PrevDynamic_R Dynamic_R ;
        PrevDynamic_S Dynamic_S ;



        //Dynamic_R =   highest( iPeriods , high() ) ;  // dynamic Resistance
        //Dynamic_S =   lowest( iPeriods , low() ) ;  // dynamic Suport


        var xHH highestiPeriods high() ) ;  // dynamic Resistance
        var xLL lowestiPeriods low() ) ;  // dynamic Suport

        Dynamic_R =   xHH ;  // dynamic Resistance 
        Dynamic_S =   xLL ;  // dynamic Suport


           
        if ( Dynamic_R != high(0) && Dynamic_R PrevDynamic_R ) {
             if ( 
        PrevDynamic_R != ) {
                
        Dynamic_R PrevDynamic_R;
                 }
        }
            

        if ( 
        Dynamic_S != low(0) && Dynamic_S PrevDynamic_S ) {        
            if ( 
        PrevDynamic_S != ) {
                
        Dynamic_S PrevDynamic_S;
                }

        debug output follows:
        Attached Files

        Comment


        • #5
          Dynamic S/R

          Hi Avery,

          I should have known you'd pick up on this idea!

          The thing is I'm not sure I made the formulation clear so I'll give you an example using the same HANS 5 min. chart you used.
          (I will make some eyeball changes to values that are very close, rounding to the closest nickle price for clarity.)

          T = time, O = open, H = high, L = low, C = close, V = value assigned.

          Begining with the first bar (big red candle):

          T = 9:30
          O = 45.10 V = 1
          H = 45.20 (rounded up) V = 1
          L = 42.10 V = 1
          C = 42.30 (rounded down) V = 2

          Every price is assigned a value, I feel closing prices are more significant so I assign a value of 2 to the close.

          T = 35
          O = 42.25 (rounded down) V = 1
          H = 43.25 (rounded up) V = 1
          L = 42.15 (rounded up) V = 1
          C = 42.60 V = 2

          T = 40
          O = 42.60 V = 1
          H = 42.75 (rounded) V = 1
          L = 41.80 V = 1
          C = 42.50 (rounded) V = 2

          At this poing the T35 and T40 values for price 42.60 would be added yielding a V = 3 for price 42.60. (all V's at the same price level are summed over the look back period)

          So based on these 3 bars there is only ONE price that has a V greater than 2 so it becomes the current S/R.

          T = 45
          O = 42.45 (rounded) V = 1
          H = 42.70 (rounded) V = 1
          L = 42.10 V = 1
          C = 42.25 (rounded) V = 2

          At this poing the T35 and T45 values for price 42.25 would be added yielding a V = 3 for price 42.25. (all V's at the same price level are summed over the look back period)

          So based on these 4 bars there are TWO prices that has a V greater than 2, and because the V for the two prices are equal a S/R zone is established.

          Continuing on I will not indicate rounding.

          T = 50
          O = 42.15 V = 1
          H = 42.95 V = 1
          L = 42.15 V = 1
          C = 42.45 V = 2

          Now it's starting to get complicated and you can see the need for a good program / EFS. What needs to be done is look back over the last 5 bars and sum the V's at the same price.

          42.45 has a V = 2 @ T50 and a V = 1 @ T45 sum V's = 3

          42.15 has V = 2 @ T50 (because the O and L are equal, each with a V = 1) and a V = 1 @ T35 sum V's = 3

          We now have several prices with a V = 3.

          42.60, 42.45, 42.25 and 42.15 so the S/R zone is 42.60 upper to 42.15 lower over these 6 bars.

          T = 55
          O = 42.50 V = 1
          H = 42.80 V = 1
          L = 42.50 V = 1 plus V = 1 @ T55 Open plus @ T40 sum V's = 4
          C = 42.75 V = 2 plus V = 1 @ T40 sum V's = 3

          S/R is now 42.50 (no zone)

          T = 10:00
          O= 42.75 V =1 plus 3 (based on prior sum) = sum V's = 4
          H = 42.85 V = 1
          L = 42.50 V = 1 plus 4 (based on prior sum) = sum V's = 5
          C = 42.65 V = 2

          S/R remains at 42.50

          I could go on but I hope this better explains what I'm trying to do.

          Over time / a look back period, the rise and fall of S/R levels could be usefull to confirm swings and breakouts. Using several periods and seeing confluence might be a very strong indicator!

          It will be interesting to see if this EFS is possible.
          OpaBert

          Comment


          • #6
            Why should you have known? LOL

            Comment


            • #7
              Basically, what you are doing is loading an 2 dimensional array, price in one element and summing V value in the other.

              This is very similiar to MARKET PROFILE except you are not using volume.

              Seems kind of complicated to me but each to their own.

              It's not really that difficult to program but it may chew up CPU cycles processing the arrays.

              Comment


              • #8
                Dynamic S/R

                The question remains ... Can someone create the EFS that will display the Dynamic S/R as outlined?

                I don't think it should take up that much more CPU time unless a very long look back period were used.

                Consider a period of 60 to represent the past hour on a 1 minute chart. Even if the OHLC of every bar were different there would only be 4 x 60 = 240 maximum prices to consider. Maybe it's because I'm NOT a programer that I can't imagine the difficulty involved.

                It seems to be an EFS that would have merit in conjunction with other technical analysis indicators.
                OpaBert

                Comment


                • #9
                  Yes.

                  Someone could create it.

                  Comment


                  • #10
                    Is this EFS similar to what your looking for?


                    http://share.esignal.com/groupconten...tals&groupid=7
                    Attached Files

                    Comment


                    • #11
                      Dynamic S/R

                      Kevin,

                      The Fractal EFS's you referenced are more in line with my original concept of Dynamic S/R Zones. Thanks for bringing them to our attention.

                      When I apply them to a chart they come much closer to what I'd expect.

                      From the number of views on this topic it seems lots of traders are interested in Dynamic S/R Zones. I wish I had more programing skill so that we could all see and effectively evaluate the method I proposed.

                      Bert

                      OpaBert

                      Comment


                      • #12
                        I have been using the subject EFS for sometime now and find it to be useful. Good luck with it.
                        Last edited by kevinmclark; 07-25-2006, 05:53 PM.

                        Comment


                        • #13
                          I FIXED IT!!

                          I guess I still have a lot to learn about eSignal code.

                          I had used var in front of Dynamic_R and Dynamic_S in the main function and for some reason that messed everything up.

                          If you look at the screen shot, you will notice I have the highest high/low for the last 5 bars along with the TRO_Dynamic_SR squares.

                          Notice in the screenshot how the support squares don't always move up and how the price drops. This will keep you on your toes!


                          PHP Code:

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

                          TRO_DYNAMIC_SR 20060722 PLOT DYNAMIC SUPPORT/RESISTANCE


                          Programmer:  Avery T. Horton, Jr.  aka *************, 


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

                          //debugClear(); 

                          function preMain() {

                              
                          setPriceStudy(true);
                              
                          setStudyTitle("TRO_DYNAMIC_SR");

                              
                          setCursorLabelName("Dyn_R"0);
                           
                              
                          setCursorLabelName("Dyn_S"1);

                              
                          setDefaultBarFgColor(Color.red,0);

                              
                          setDefaultBarFgColor(Color.blue,1);

                              
                          setDefaultBarThickness(2,0); 
                              
                          setDefaultBarThickness(2,1); 

                              
                          setPlotType(PLOTTYPE_SQUARE ,0);
                              
                          setPlotType(PLOTTYPE_SQUARE ,1); 


                          }

                          var 
                          Dynamic_R            0;
                          var 
                          Dynamic_S         0;
                          var 
                          OldDynamic_R     0;
                          var 
                          OldDynamic_S     0;
                          var 
                          PrevDynamic_R     0;
                          var 
                          PrevDynamic_S     0;
                           
                          askForInput();


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

                              var 
                          iAlert = new FunctionParameter("iAlert"FunctionParameter.BOOLEAN);
                              
                          iAlert.setDefaulttrue );

                              var 
                          iPeriods = new FunctionParameter("iPeriods"FunctionParameter.NUMBER);
                              
                          iPeriods.setDefault05 );

                          function 
                          mainiAlert iPeriodsiDebug  ) {

                              if (
                          close(-1)==null
                                  return;
                                 

                               if ( 
                          PrevDynamic_R==null)  PrevDynamic_R 0;

                               if ( 
                          PrevDynamic_S==null)  PrevDynamic_S 0;


                              if( 
                          getBarState() == BARSTATE_NEWBAR && getDay() != getDay(-1) ) {
                                  
                          Dynamic_R =    high() ;  // dynamic Resistance
                                  
                          Dynamic_S =    low() ;  // dynamic Suport
                              
                          }


                          if ( 
                          Dynamic_R != PrevDynamic_R ) {
                              
                          OldDynamic_R PrevDynamic_R 
                              }
                                  
                          if ( 
                          Dynamic_S != PrevDynamic_S ) {
                              
                          OldDynamic_S  PrevDynamic_S 
                              }
                              
                          OldDynamic_R PrevDynamic_R ;
                          OldDynamic_S PrevDynamic_S ;


                          //debugPrint( "1 PrevDynamic_S:      " + ( PrevDynamic_S ) + "\n" );

                          PrevDynamic_R Dynamic_R ;
                          PrevDynamic_S Dynamic_S ;


                          //debugPrint( "2 PrevDynamic_S:      " + ( PrevDynamic_S ) + "\n" );


                          var xHH highestiPeriods high() ) ;  // dynamic Resistance
                          var xLL lowestiPeriods low() ) ;  // dynamic Suport

                          Dynamic_R =   formatPriceNumber(xHH)*;  // dynamic Resistance 
                          Dynamic_S =   formatPriceNumber(xLL)*// dynamic Suport


                             
                          if ( Dynamic_R != high(0) && Dynamic_R PrevDynamic_R ) {
                               if ( 
                          PrevDynamic_R != ) {
                                  
                          Dynamic_R PrevDynamic_R;
                                   }
                          }
                              

                          if ( 
                          Dynamic_S != low(0) && Dynamic_S PrevDynamic_S ) {        
                              if ( 
                          PrevDynamic_S != ) {
                                  
                          Dynamic_S PrevDynamic_S;
                                  }
                          }

                              
                              
                              if (
                          Dynamic_R == null || Dynamic_S == null ) {
                                  return;
                              } else {


                          if(
                          iDebug == true){

                          debugPrint"--------------------------------"    "\n" );

                          debugPrint"DYNAMIC SUPPORT:    " + ( Dynamic_S )  + "\n" );
                          debugPrint"LOW:                " + ( low(0) ) + "\n" ); 
                          debugPrint"PrevDynamic_S:      " + ( PrevDynamic_S ) + "\n" );
                          debugPrint"xLL:                " + ( formatPriceNumber(xLL)*) + "\n" ); 

                          debugPrint"DYNAMIC RESISTANCE: " + ( Dynamic_R ) + "\n" ); 
                          debugPrint"HIGH:               " + ( high(0) )  + "\n" );
                          debugPrint"PrevDynamic_R:      " + ( PrevDynamic_R ) +  "\n" ); 
                          debugPrint"xHH:                " + ( formatPriceNumber(xHH)*1) + "\n" ); 

                          debugPrintgetValue"Time" )      + "\n" );
                          debugPrint"------- TRO_DYNAMIC_SR ---------"    "\n" );

                          }

                          //  ALERT 

                              
                          if(   close(0) >= Dynamic_R ){
                              
                          Alert.addToList(getSymbol(), Dynamic_R +" DYNAMIC RESISTANCE"Color.blueColor.black);
                                if( 
                          iAlert == true Alert.playSound("ding.wav");

                          //      debugPrint("DYNAMIC RESISTANCE: " + formatPriceNumber( Dynamic_R  ) + " " +  getValue( "Time" ) + "\n" ); 
                               
                          }
                           
                              if(  
                          close(0) <= Dynamic_S ){
                              
                          Alert.addToList(getSymbol(), Dynamic_S +" DYNAMIC SUPPORT"Color.redColor.black);
                                  if( 
                          iAlert == true Alert.playSound("ding.wav");

                          //      debugPrint("DYNAMIC SUPPORT: " + formatPriceNumber( Dynamic_S ) + " " +  getValue( "Time" ) + "\n" );  
                               
                          }


                           if ( 
                          isLastBarOnChart() == true ) { 
                           
                                
                          //print a line of text to that window 
                          //      debugPrint( "DYNAMIC SUPPORT:    " + formatPriceNumber( Dynamic_S  ) + "\n" ); 
                          //      debugPrint( "DYNAMIC RESISTANCE: " + formatPriceNumber( Dynamic_R ) + "\n" ); 

                          //     debugPrint( "iPeriods: " + formatPriceNumber( iPeriods ) + "\n" ); 
                             



                                  return new Array( 
                          Dynamic_R ,Dynamic_S  );
                              }
                          }

                          /*


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

                          debugPrint( "DYNAMIC SUPPORT:    " + formatPriceNumber( Dynamic_S )  + "\n" );
                          debugPrint( "LOW:                " + formatPriceNumber( low(0) ) + "\n" ); 
                          debugPrint( "PrevDynamic_S:      " + formatPriceNumber( Dynamic_S ) + "\n" );
                          debugPrint( "xLL:                " + formatPriceNumber( xLL ) + "\n" ); 

                          debugPrint( "DYNAMIC RESISTANCE: " + formatPriceNumber( Dynamic_R ) + "\n" ); 
                          debugPrint( "HIGH:               " + formatPriceNumber( high(0) )  + "\n" );
                          debugPrint( "PrevDynamic_R:      " + formatPriceNumber( Dynamic_R ) +  "\n" ); 
                          debugPrint( "xHH:                " + formatPriceNumber( xHH ) + "\n" ); 

                          debugPrint( getValue( "Time" )      + "\n" );
                          debugPrint( "------- TRO_DYNAMIC_SR ---------"    + "\n" );
                          */ 
                          Attached Files

                          Comment


                          • #14
                            Dynamic S/R Zones

                            Interesting fix but still not truly representative of the original Dynamic S/R proposed when this thread was begun.

                            We are still waiting for someone with the coding skill to take up the cause.
                            OpaBert

                            Comment


                            • #15
                              Re: Dynamic S/R Zones

                              I apologize.

                              It was NOT my intention to code what you had proposed.

                              I merely converted my TradeStation indicator into a eSignal study.

                              When I went to post, I saw this thread and figured I should post here instead of having a repetitive thread.

                              If you like, I will delete my posts from your thread.

                              I didn't mean to trepass.




                              Originally posted by OpaBert
                              Interesting fix but still not truly representative of the original Dynamic S/R proposed when this thread was begun.

                              We are still waiting for someone with the coding skill to take up the cause.

                              Comment

                              Working...
                              X