Announcement

Collapse
No announcement yet.

"Current bar" question

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

  • "Current bar" question

    Is there any way to EFS code, so that the "current bar" information displayed on my Wizard "non price studies" are on every tick and not on CLOSE of the current bar.

    'setComputeOnClose(true)' is not in the preMain as advised in the script but even if I put 'setComputeOnClose(false)' in the preMain it is still called on CLOSE, so I'm at a loss as to how to proceed.

    If anyone can point me in the right direction or even better supply me with the script change I need, then I can then use the editor to amend and save, rather than use the wizard.

    Below is an example of a simple background colour change on Stochastics and I am wanting the current bar to change colours on the tick if applicable and not on CLOSE in this instance.

    Many thanks for any help,
    TIKTOK

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


    //{{EFSWizard_Declarations
    var vStoch14_3 = new StochStudy(14, 3, 4);
    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(false);
    setStudyTitle("");
    //}}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
    if (
    vStoch14_3.getValue(StochStudy.FAST) > vStoch14_3.getValue(StochStudy.SLOW)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vStoch14_3.getValue(StochStudy.FAST) < vStoch14_3.getValue(StochStudy.SLOW)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}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() {
    setBarBgColor(Color.RGB(204,224,246));
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    setBarBgColor(Color.RGB(255,195,195));
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

  • #2
    Re: &quot;Current bar&quot; question

    Tiktok
    The formula you posted is computing on every tick and not at the close of the bar
    As an aside setComputeOnClose() does not take any arguments so it is executed regardless of whether you write setComputeOnClose(true) or setComputeOnClose(false)
    If you are using version 10.6 [or earlier] and this formula is computing only at the close of the bar then that is because you have the global compute on close enabled [see Tools-> EFS-> Settings]
    Alex


    Originally posted by Tiktok
    Is there any way to EFS code, so that the "current bar" information displayed on my Wizard "non price studies" are on every tick and not on CLOSE of the current bar.

    'setComputeOnClose(true)' is not in the preMain as advised in the script but even if I put 'setComputeOnClose(false)' in the preMain it is still called on CLOSE, so I'm at a loss as to how to proceed.

    If anyone can point me in the right direction or even better supply me with the script change I need, then I can then use the editor to amend and save, rather than use the wizard.

    Below is an example of a simple background colour change on Stochastics and I am wanting the current bar to change colours on the tick if applicable and not on CLOSE in this instance.

    Many thanks for any help,
    TIKTOK

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


    //{{EFSWizard_Declarations
    var vStoch14_3 = new StochStudy(14, 3, 4);
    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(false);
    setStudyTitle("");
    //}}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
    if (
    vStoch14_3.getValue(StochStudy.FAST) > vStoch14_3.getValue(StochStudy.SLOW)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vStoch14_3.getValue(StochStudy.FAST) < vStoch14_3.getValue(StochStudy.SLOW)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}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() {
    setBarBgColor(Color.RGB(204,224,246));
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    setBarBgColor(Color.RGB(255,195,195));
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

    Comment


    • #3
      Re: Re: &quot;Current bar&quot; question

      Thanks for that Alexis . . . your input is always appreciated.

      I am slightly confused though, as the Stochastics indicator itself can cross over several times with the "tick" during one bar state (say 5 min template) but the background colour will stay constant on that bar. Is there a way of emulating the crossover states in the bar background colour . . . at present they do not reflect the tick changes, even as you the script is recorded on the tick.

      I have scoured the forums and been through the tutorials to no avail at the moment but if you understand my needs and it is possible to achieve, then any pointers would be gratefully received.

      PS. Am running 10.6 and will look into your tools suggestion thank you.

      Best regards,
      Tiktok (Peter)
      Last edited by tiktok; 04-17-2012, 06:00 AM.

      Comment


      • #4
        Re: Re: Re: &quot;Current bar&quot; question

        Correct as usual Alexis . . . had the formula "compute on close" in the formula engine settings with running 10.6

        You are a great asset to the forum and eSignal.

        Many thanks once again.

        Best regards,
        Tiktok

        Comment


        • #5
          Re: Re: Re: Re: &quot;Current bar&quot; question

          Tiktok
          You are welcome
          Alex


          Originally posted by Tiktok
          Correct as usual Alexis . . . had the formula "compute on close" in the formula engine settings with running 10.6

          You are a great asset to the forum and eSignal.

          Many thanks once again.

          Best regards,
          Tiktok

          Comment

          Working...
          X