Announcement

Collapse
No announcement yet.

Custom Indicator no longer changing color in realtime on displayed chart.

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

  • Custom Indicator no longer changing color in realtime on displayed chart.

    I have an EFS study built with the wizard which used to always change color realtime on a 5 minute chart and no doesn't do so without having to "reload" the formula.

    This a a major problem for me as I trade for a living and am missing signals until I reload the formula. For a very long time I did not have this problem and the Bar Backgroung used to change on a realtime basis.

    Thanks very much.

    Here is the statement:

    if(Strategy.isLong()) {
    setBarBgColor(Color.green);
    } else if(Strategy.isShort()) {
    setBarBgColor(Color.red);
    Last edited by demarcog; 09-13-2005, 06:04 AM.
    Glen Demarco
    [email protected]

  • #2
    demarcog
    The snippet of code you posted does not provide enough information on where the problem may be.
    Post the code or a more representative sample of your efs that illustrates the problem
    Alex

    Comment


    • #3
      Alex,

      Sorry about that Here is the code:
      You can see when the oscillator value goes up or down relative to the last value I generate a buy or sell and paint the bcakground accordingly. I basically load the formula and keep the chart open all day and it would always change. Recently I have to keep reloading the formula to get the color to change.

      This is a somewhat unrelated problem but I'm seeing some apparently inconsistent values between the ATRSTUDY study when added to a chart and the ATRStudy.ATR function within a EFS strategy. I'm assuming the ATRStudy chart study with a 10 interval period is the same as: ATRStudy(10). I'm getting buy and sell signals in another strategy based on values out of the range on the displayed on a chart or when the data is viewed in the download data option. If you want I can open a seperate thread on this, thanks for all your help.


      Thanks



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


      //{{EFSWizard_Declarations
      var vLastAlert = -1;
      var vHour = 0;
      var vStarttime =0;
      var vEndtime =24;
      var vATR = new ATRStudy(10);

      //}}EFSWizard_Declarations 26449


      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("S0-Signal");
      //}}EFSWizard_PreMain 7395

      }

      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 ( vATR.getValue(ATRStudy.ATR) > vATR.getValue(ATRStudy.ATR, -1)



      ) onAction1()
      //}}EFSWizard_Expression_1 47139

      //{{EFSWizard_Expression_2
      else if (
      vATR.getValue(ATRStudy.ATR) < vATR.getValue(ATRStudy.ATR, -1)

      ) onAction2();
      if(Strategy.isLong()) {
      setBarBgColor(Color.green);
      } else if(Strategy.isShort()) {
      setBarBgColor(Color.red);
      //}}EFSWizard_Expression_2 45093

      //}}EFSWizard_Expressions 118550


      //{{EFSWizard_Return
      return null;
      //}}EFSWizard_Return 2256
      }
      }

      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() {
      if (vLastAlert != 1) Strategy.doLong("", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
      // if (vLastAlert != 1) Strategy.setStop(low()-.0010);
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1 34384

      //{{EFSWizard_Action_2
      function onAction2() {
      if (vLastAlert != 2) Strategy.doShort("", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
      // if (vLastAlert != 2) Strategy.setStop(high()+.0010);
      vLastAlert = 2;
      }
      //}}EFSWizard_Action_2 36521

      //}}EFSWizard_Actions 87094
      Glen Demarco
      [email protected]

      Comment


      • #4
        demarcog
        Your strategy is set to use the Open (ie MARKET) of the NEXTBAR as the entry which in real time is not valid since that value does not exist when your condition returns true. That value instead exists (up to the prior bar) when you reload the efs which explains why the background colors change on historical bars.
        Replace Strategy.MARKET and Strategy.NEXTBAR with Strategy.CLOSE and Strategy.THISBAR respectively and you will see that the script will work correctly. Better yet paint the background directly without using the Strategy Object which should really be limited to Back Testing only.
        Alex

        Comment


        • #5
          demarcog
          As to the differences between the ATR in Basic Studies and the efs version I am not seeing that. The enclosed image shows the efs versions from the Builtin and the EFS2 Custom folders compared to the Basic Study version and as far as I can see the values are consistently the same
          Alex

          Comment


          • #6
            Alex,

            Thank you very much on both counts. The ATR issue was my problem. I appreciate your help.
            Glen Demarco
            [email protected]

            Comment

            Working...
            X