Announcement

Collapse
No announcement yet.

Help With Trading The Trend2.efs, Please?

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

  • Help With Trading The Trend2.efs, Please?

    Hello,
    I'm trying to change the"leg" colors in this study so that the up line is one color, the down line is another color and the upper horizontal & lower horizontal lines are also separate colors. I'm not having any luck. Can this be done? Thank you in advance.
    Diane

  • #2
    Diane
    The first thing you need to do is create a global variable called ret1 and set it to null ie

    PHP Code:
    var ret1 null
    Then as the first line of the if(getBarStateInterval() condition insert

    PHP Code:
    ret1=ret
    At that point you can write your condition to color the plot after the one that colors the price bars. For example

    PHP Code:
    if(ret>ret1){
        
    setBarFgColor(Color.lime);
    }
    if(
    ret<ret1){
        
    setBarFgColor(Color.red);

    You will also need to add the following statement in preMain

    PHP Code:
    setPlotType(PLOTTYPE_INSTANTCOLORLINE); 
    Lastly set the default color for the plot to (for example) Color.lightgrey
    Alex

    Comment


    • #3
      Diane
      In the example I provided in my prior reply the "flat" sections would end up being painted with the default color (whatver you may have chosen for it).
      If instead you wanted them to be of the same color as they were before going "flat" then you would need to make a few additions to the logic.
      The first thing is to create two global variables called for example vColor and vColor1 and set them both to null.
      Then inside the if(getBarStateInterval() condition you would add the following

      PHP Code:
      vColor1=vColor
      Then you would need to change the conditions to color the plot to the one showed below
      Hope this helps
      Alex

      PHP Code:
      if(ret>ret1){//if the stop line is greater than the prior
              
      setBarFgColor(Color.lime);//set this color
              
      vColor="lime";//assign the color name to the variable
          
      }
          if(
      ret<ret1){//if lesser
              
      setBarFgColor(Color.red);//set this color
              
      vColor "red";//assign the color name to the variable
          
      }
          if(
      ret==ret1){//if equal to the prior
              
      if(vColor1=="lime"){//if the prior was "lime"
                  
      setBarFgColor(Color.lime);//set this color
              
      }
              if(
      vColor1=="red"){//if the prior was "red"
                  
      setBarFgColor(Color.red);//set this color
              
      }
          } 

      Comment


      • #4
        Hi Alex!
        This is SUPER! Thank you. Your study works beautifully with my T3. Thanks again!
        Diane

        Comment


        • #5
          Diane
          You are most welcome.
          BTW you also asked how to color the vertical sections of the plot. Those are the lines that join the data points of the plot (which are colored with setBarFgColor()) and their color is defined by that of the data point. You can however choose to not plot these "joining lines" by using a different plot type. If you want to try this replace INSTANTCOLORLINE in setPlotType(PLOTTYPE_INSTANTCOLORLINE) with FLATLINES (which will plot only horizontal lines) or with DOT (ie the same as with the Parabolic)
          Alex

          Comment


          • #6
            Hi Alex,
            Happy Saturday! Thanks for the additional info. Wow, I really like the _DOT plot. But I like the vertical lines as well. Such a dilema. However, maybe I can have both. If I download the study again & use the 2nd one for my vertical lines, that should work,right? Thanks for all this great information. You are terrific! Hope you have a great day!
            Diane

            Comment


            • #7
              Diane

              If I download the study again & use the 2nd one for my vertical lines, that should work,right?

              If you mean that the second copy of the study would be used to plot only the vertical lines then that would not be possible. Those are the lines that join the data points (like in a moving average) and you can either display them together with the horizontal lines or hide them (using either of the alternate plot types I suggested earlier).
              BTW there are also two additional plot types which are not yet documented and that you may want to try and those are CIRCLES and SQUARES
              Have a great weekend
              Alex

              Comment


              • #8
                Thanks, Alex. I followed your suggestion & it works great!
                Diane

                Comment

                Working...
                X