Announcement

Collapse
No announcement yet.

cleaning up the display

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

  • cleaning up the display

    I am using the following efs to plot the pro rata volume on a 5min chart. The estimated volume for each complete bar is plotted in grey behind the actual volume bar.

    If no data arrrives in the last 15 secs of a bar, the pro rata grey bar remains uncleared on "old" bars. Is there a way that I can ensure that the grey bar is cleared for all bars prior to the current bar? At present I clean up the chart every so often by doing a manual "reload".





    /************************************************** *******
    This eSignal script plots volume in a typical manner with
    an underlay of the prorated volume until the end of the
    five minute bar. The first plot is the prorated volume and
    the second is the actual current volume. This is so the
    actual volume plots on top of the prorated volume.

    StephenR0

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

    function preMain() {

    setPriceStudy(false); // so it gets its own section
    setStudyTitle("prv5");

    //set up the first plot
    setCursorLabelName("Prorated", 0);
    setDefaultBarFgColor(Color.lightgrey, 0);
    setDefaultBarThickness(4,0);
    setPlotType(PLOTTYPE_HISTOGRAM, 0);

    // set up the second plot
    setCursorLabelName("Volume", 1);
    setDefaultBarFgColor(Color.black, 1); // this is changed below
    setDefaultBarThickness(2,1);
    setPlotType(PLOTTYPE_HISTOGRAM, 1);

    setStudyMin (0);

    }

    /* The main function is called with each incoming data item. This
    means that nothing will plot if no data comes in. */

    function main() {

    var Today = new Date ();
    var Minutes = Today.getMinutes();
    var Seconds = Today.getSeconds();
    var BarSeconds = 0;
    var Vol = 0;
    var Open = 0;
    var Close = 0;
    var VolP = 0;

    Vol = volume();
    Open = open();
    Close = close();

    if(Vol == null){
    return;
    }

    /* Set the volume bar color if higher or lower. */
    if (Close >= Open)
    setBarFgColor(Color.black, 1);
    else
    setBarFgColor(Color.red, 1);

    // First, determine how many seconds we are into this bar.
    Minutes = Minutes - (Math.floor(Minutes/5)*5);
    BarSeconds = Minutes*60 + Seconds;

    /* Now, prorate the current volume for the rest of the bar.
    Don't plot for the first thirty seconds to try to dampen some of the
    wild swings that would happen otherwise. In addition, don't plot
    the prorated volume for the previous bars. */
    if (BarSeconds <= 30 || BarSeconds > 285 || getCurrentBarIndex() < 0){
    VolP = 0;
    } else {
    VolP = (Vol/BarSeconds)*300;
    }

    /* Limit the scaling of the prorated volume because wild swings
    aren't real anyway. */
    if (VolP >= 25000){
    VolP = 25000;
    setBarFgColor(Color.RGB(255,192,192), 0); // light pink
    } else {
    setBarFgColor(Color.lightgrey, 0);
    }

    // Return the array in the right order for our plots.
    return new Array (VolP, Vol);

    }
    Attached Files

  • #2
    UK TRADER

    I find your grey lines channels interesting in the ES #F chart. I would like to try them. Would you mind posting the efs or formula. Thanks for your help.
    Mark

    Comment


    • #3
      Hi Mark

      The grey channel lines are drawn manually.

      David

      Comment


      • #4
        Hello David,

        You can use the setBar() function to change the value of the previous bar values at BARSTATE_NEWBAR to create the affect you're looking for. Try adding the following to your formula.

        PHP Code:
        if (getBarState() == BARSTATE_NEWBAR) {
            
        //setBar( TYPE (Value|Color|Style|Thickness), BarOffset, SeriesIndex, Value )
            
        setBar(Bar.Value, -100);

        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Thanks Jason, that works a treat. For some reason it cleared the bar that is 2 bars prior to the newest bar so I just changed the code to read

          setBar(Bar.Value, 0, 0, 0);

          and it now clears the prior bar as soon as a new bar starts.

          Comment

          Working...
          X