Announcement

Collapse
No announcement yet.

reload EFS script in realtime

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

  • reload EFS script in realtime

    Hello,
    I was wondering if there was a way to reload my EFS script in real time? Currently I have a script that prints the high and low of the day as well as the high and low of every 60mins. Currently I have to keep reloading the script manually every time there is a new high or low printed. The script reloads every time i change time frames, but since I have this script running on about 12 charts simultaneously it takes away my concentration from actually trading, which is the complete opposite of what the script was designed for in the first place.

    Simply put, I just want my script to reload automatically if there is a new high or new low made both for the entire day and for each 60min period.

    I was reading through this thread, http://forum.esignalcentral.com/show...day*#post23172

    but it made no sense to me. Is there a way I can just insert the reload() function without having to declare variables? Or do I have to declare variables to make it automatically refresh when there is a new high/low?

    Thanks in advance,
    Brian

    Here's what I have so far:

    Generated EFS Code

    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("for esignal forums");
    setCursorLabelName("HIGH", 0);
    setCursorLabelName("LOW", 1);
    setCursorLabelName("50%", 2);
    setCursorLabelName("1Day50%", 3);
    setCursorLabelName("1DayHIGH", 4);
    setCursorLabelName("1DayLOW", 5);
    setDefaultBarStyle(PS_DASH, 0);
    setDefaultBarStyle(PS_DASH, 1);
    setDefaultBarStyle(PS_DOT, 2);
    setDefaultBarStyle(PS_DOT, 3);
    setDefaultBarStyle(PS_SOLID, 4);
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarFgColor(Color.grey, 0);
    setDefaultBarFgColor(Color.grey, 1);
    setDefaultBarFgColor(Color.blue, 2);
    setDefaultBarFgColor(Color.red, 3);
    setDefaultBarFgColor(Color.black, 4);
    setDefaultBarFgColor(Color.black, 5);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(2, 1);
    setDefaultBarThickness(2, 2);
    setDefaultBarThickness(3, 3);
    setDefaultBarThickness(3, 4);
    setDefaultBarThickness(3, 5);
    setPlotType(PLOTTYPE_FLATLINES, 0);
    setPlotType(PLOTTYPE_FLATLINES, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    setPlotType(PLOTTYPE_FLATLINES, 3);
    setPlotType(PLOTTYPE_FLATLINES, 4);
    setPlotType(PLOTTYPE_FLATLINES, 5);
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    //}}EFSWizard_Expression_1

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return new Array(
    high(0, inv("60")),
    low(0, inv("60")),
    hl2(inv("60")),
    hl2(inv("390")),
    high(0, inv("390")),
    low(0, inv("390"))
    );
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //}}EFSWizard_Actions

  • #2
    DBBLI,

    Is the issue that you want to redraw all of the historical lines?

    If so, then you will need to use reloadEFS() and put it in a conditional statement that checks to see if the current High (or current Low) is less than the old "Highest High" or "Lowest Low".

    When using reloadEFS() it is rather easy to code an infinite loop, and lock up eSignal. You may want to look carefully at how others have used this command before attempting to use it.

    I would also recommend using debug statements to make sure that the you are getting the expected behavior before actually adding the reloadEFS() command to your EFS.

    Garth
    Garth

    Comment


    • #3
      Garth,

      That's exactly what I'm trying to do - redraw all the lines that were previously printed on the chart so that they reflect the new reality of a new high/low made.

      I've only seen examples that had variables declared and none with conditional statements. If you could provide an example of what the condition statement would look like that would be SOOOO helpful.

      I'm assuming it would be either an IF statement or some kind of BOOLEAN statement, something on the order of:

      {
      IF close() <= high(),
      Return null,


      ELSE IF close() > high()

      Return reloadEFS()
      }

      See I guess this is where I get confused. How do you quantify a "new high" ?

      -Brian


      Originally posted by gspiker
      DBBLI,

      Is the issue that you want to redraw all of the historical lines?

      If so, then you will need to use reloadEFS() and put it in a conditional statement that checks to see if the current High (or current Low) is less than the old "Highest High" or "Lowest Low".

      When using reloadEFS() it is rather easy to code an infinite loop, and lock up eSignal. You may want to look carefully at how others have used this command before attempting to use it.

      I would also recommend using debug statements to make sure that the you are getting the expected behavior before actually adding the reloadEFS() command to your EFS.

      Garth

      Comment


      • #4
        DBBLI,

        First I would look at this, which describes how to protect yourself from an infinite loop when using reloadEFS().

        http://forum.esignalcentral.com/show...threadid=28875


        You can then look at this example:

        http://forum.esignalcentral.com/show...S+highest+high

        It is the second one down in the list (hilo.efs). I would code this differently now, but it gives you an idea.

        Honestly, it may be easier to ask someone to code this for you. It sounds like you are just getting up to speed on this EFS stuff, and realodEFS() is a bit tricky.

        Garth
        Garth

        Comment


        • #5
          Hi,

          You can also create a global variable that tracks your current high and, as Garth suggested, when the high changes, update the current high global variable and reload the efs using reloadEFS() inside a conditional. I am using reload in realtime and it works well.
          Regards,
          Jane

          Comment

          Working...
          X