Announcement

Collapse
No announcement yet.

Here is a style question

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

  • Here is a style question

    When you have two points in the non-price study portion of the chart, and you would like to color the indicator line when it crosses above a certain level, how can you get it to do that before the point that satisfies that up to that point?

    if ( prob >0 ){ // set color Green

    setBarFgColor(Color.green);
    setBarThickness(3);
    }

    if ( prob <= 0 ){ // set color Red

    setBarFgColor(Color.red);
    setBarThickness(3);
    }
    Attached Files
    Last edited by Roderick; 08-22-2004, 09:08 PM.

  • #2
    I had this problem a while back...

    You have to use setBar() to adjust the indicator so it colors properly.

    (from the EFS help file).

    setBar()

    setBar( TYPE (Value | Color | Style | Thickness), BarOffset, SeriesIndex, Value )

    setBar( TYPE (Value | Color | Style | Thickness), BarOffset, Value | ArrayOfValues )


    · Type: The specific property that you want to modify. See Valid Types below:
    · BarOffset: The offset back to the bar you wish to modify.

    · SeriesIndex: (Optional). Specify the specific return value that you wish to modify.
    · Value: The new value.

    Valid Types

    Bar.Value

    Bar.Style

    Bar.FgColor

    Bar.BgColor

    Bar.Thickness

    This function allows you to adjust the value and/or the properties of a prior bar of a study being displayed. For example, if you are calculating and displaying 2 moving average studies in your script, you could use the setBar() function to change the actual value, color, line style or thickness of a previously-displayed value from either one of the studies or even both of the studies.

    Example:

    //The example below shows how the setBar() function can be used to change

    //the value, color and bar thickness of previously displayed values of two moving

    //averages.

    //Define the two Moving Average studies that we will display in our chart

    var study1 = new MAStudy(5, 0, "Close", MAStudy.EXPONENTIAL);

    var study1 = new MAStudy(25, 0, "Close", MAStudy.EXPONENTIAL);

    function main( frPeriod ) {

    var nMA1;

    var nMA2;

    //retrieve the MA values for the current bar
    nMA1 = studyF.getValue(MAStudy.MA);
    nMA2 = studyS.getValue(MAStudy.MA);

    //if the FastMA minus the SlowMA is greater than 10 points, we will use the setBar()
    //function to modify previously displayed values of both moving averages. Once this
    //change takes place, your Advanced Chart will update your display to reflect these
    //changes.

    if ( (nMA1 - nMA2) > 10 ) {
    //set the value 5 bars ago of the FastMA to 10.75

    //set the value 5 bars ago of the SlowMA to 9.95
    setBar( Bar.Value, -5, new Array( 10.75, 9.95 ) );

    //set the color of the FastMA 5 bars ago to black
    //set the color of the SlowMA 5 bars ago to yellow
    setBar( Bar.FgColor, -5, new Array( Color.black, Color.yellow ) );

    //set the bar thickness of the FastMA 5 bars ago to 2
    //set the bar thickness of the SlowMA 5 bars ago to 3
    setBar( Bar.Thickness, -5, new Array( 2, 3 ) );
    }

    //return the current MA values to be displayed
    return new Array( nMA1, nMA2 );

    }

    Other Examples:

    //set the value of the prior bar of the first study you are returning
    //from your script to 22.
    setBar( Bar.Value, -1, 22 );

    //set the value of the prior bar of the 3rd study you are returning
    //from your script to 25.
    setBar( Bar.Value, -1, 3, 25 );

    //set the line style of the first study returned from your script to PS_SOLID (3 bars ago)
    setBar( Bar.Style, -3, 2, PS_SOLID );

    //Assume your script is returning 3 values to be plotted. The following code will change

    //the backround color of each study (at a point 10 bars ago) to blue, green and yellow respectively.
    setBar( Bar.BgColor, -10, new Array( Color.blue, Color.green, Color.yellow ) );
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Roderick
      In preMain() insert setPlotType(PLOTTYPE_INSTANTCOLORLINE).
      That will color the line from the prior point forward using the current color.
      Alex

      Comment


      • #4
        Thank You

        That's two(2) ways to do it. While neither is exactly what I wanted, I am very much grateful.
        Last edited by Roderick; 08-22-2004, 09:06 PM.

        Comment


        • #5
          ok - let's readdress your question..

          Do you want to color only the two points of the line (like when Stochastics crosses above 80% - to color it green (or whatever)?

          Or do you want to color a bunch of previous Sto values green up to the point (and maybe after) it crosses the 80% level?

          There are ways to accomplish both, but without more info - we might give you the wrong advice.

          B
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            Reply to Doji

            Did you see my attachment?(ind quest0.bmp) I was hoping to color the portion of the line above 0 which was between the two points. Alexis' reply was the quick and dirty way to get it done. Thanks.( I don't suppose any bitmapping would be possible. )

            Comment


            • #7
              Roderick
              I think I now understand what you are asking What you want to do is color the line that connects the points in two colors one from the start of the line to the threshold level (for example in red from -1 to 0) and in another color from the threshold level to the end point of the line (for example in green from 0 to 1)
              If that is the case then I do not believe it is possible. The line can either use the color of the last point going forwards or from the last point backwards (using the suggested setPlotType(PLOTTYPE_INSTANTCOLORLINE)
              Alex

              Comment

              Working...
              X