Announcement

Collapse
No announcement yet.

New Strategy

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

  • New Strategy

    Please,
    I would like to make a formula this way:

    When SMavg, 8, C > SMavg, 21, C and
    RSI, 14, C > 50 and
    BandWidth > X
    Set bar color Lime

    When SMavg, 8, C < SMavg, 21, C and
    RSI, 14, C < 50 and
    BandWidth > X
    Set bar color Red

  • #2
    Hi Barros,
    I put in the SMA and RSI variables. I was not sure what you meant by bandwidth, but if you open this in the Formula Wizard then you can add the condition you want. If you want to explain the desired bandwidth variable I can help you put that in.

    chris

    Comment


    • #3
      This time with the efs.
      Attached Files

      Comment


      • #4
        After I thought about it, I was able to add the bandwidth <> condition you asked for. Attached is the new efs. Hope it helps.

        chris
        Attached Files

        Comment


        • #5
          Dear Chris,
          Thank you for your attention. Barros

          THE "X" IS A VARIABLE FOR EACH INSTRUMENT.
          BANDWIDTH FORMULA:
          /************************************************** **************************************************
          Copyright © eSignal, a division of Interactive Data Corporation. 2003. All rights reserved.
          This sample eSignal Formula Script (EFS) may be modified and saved under a new
          filename; however, eSignal is no longer responsible for the functionality once modified.
          eSignal reserves the right to modify and overwrite this EFS file with each new release.
          ************************************************** ************************************************** */

          /*********************************************
          BandWidth
          10/29/2003 John Bollinger
          Copyright 2003 Bollinger Capital Management

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

          function preMain() {
          setStudyTitle("BandWidth");
          setCursorLabelName("BW", 0);
          setCursorLabelName("Floor", 1);
          }

          var bb = new BollingerStudy(20, "Close", 2.0);

          function main() {
          var vUpper = bb.getValue(BollingerStudy.UPPER);
          var vLower = bb.getValue(BollingerStudy.LOWER);
          var vMiddle = bb.getValue(BollingerStudy.BASIS);

          if(vUpper == null || vLower == null || vMiddle == null)
          return 0.0;

          return new Array((vUpper - vLower) / vMiddle * 100, 0.0);

          }

          Comment


          • #6
            Dear Chris,
            I changed the "condicional strategy2", but there is a error that seems to be in the line 55.
            Could you help me, please?

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


            //{{EFSWizard_Declarations

            var vSMA2 = new MAStudy(8, 0, "Close", MAStudy.SIMPLE);
            var vSMA8 = new MAStudy(21, 0, "Close", MAStudy.SIMPLE);
            var vRSI8 = new RSIStudy(14, "Close");
            var vBollinger20 = new BollingerStudy(20, "Close", 2);
            var vLastAlert = -1;

            //}}EFSWizard_Declarations 27723


            function preMain() {
            //{{EFSWizard_Code_PreMain_setPriceBarColor
            setColorPriceBars(true);
            //}}EFSWizard_Code_PreMain_setPriceBarColor 3448
            /**
            * 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("conditional strategy2");
            //}}EFSWizard_PreMain 6821

            }

            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 (
            vSMA8.getValue(MAStudy.MA) > vSMA21.getValue(MAStudy.MA) &&
            vRSI14.getValue(RSIStudy.RSI) > 50 &&
            ((vBollinger20.getValue(BollingerStudy.UPPER)) - (vBollinger20.getValue(BollingerStudy.LOWER)))>30
            ) onAction1()
            //}}EFSWizard_Expression_1 29258

            //{{EFSWizard_Expression_2
            else if (
            vSMA8.getValue(MAStudy.MA) < vSMA21.getValue(MAStudy.MA) &&
            vRSI14.getValue(RSIStudy.RSI) < 50 &&
            ((vBollinger20.getValue(BollingerStudy.UPPER) - (vBollinger20.getValue(BollingerStudy.LOWER)))>30
            ) onAction2();
            //}}EFSWizard_Expression_2 31951

            //}}EFSWizard_Expressions 82089


            //{{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() {
            setPriceBarColor(Color.RGB(0,255,0));
            if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
            vLastAlert = 1;
            }
            //}}EFSWizard_Action_1 23225

            //{{EFSWizard_Action_2
            function onAction2() {
            setPriceBarColor(Color.RGB(255,0,0));
            if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
            vLastAlert = 2;
            }
            //}}EFSWizard_Action_2 22409

            //}}EFSWizard_Actions 68512


            Last edited by Barros; 03-28-2004, 06:24 AM.

            Comment


            • #7
              change line 55 to

              vBollinger20.getValue(BollingerStudy.UPPER) - vBollinger20.getValue(BollingerStudy.LOWER)>30
              ) onAction2();

              Comment


              • #8
                Ok.
                Thanks Dloomis
                Last edited by Barros; 03-28-2004, 06:20 AM.

                Comment


                • #9
                  Ok Friends,
                  The "New Strategy" is correct:

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


                  //{{EFSWizard_Declarations

                  var vSMA8 = new MAStudy(8, 0, "Close", MAStudy.SIMPLE);
                  var vSMA21 = new MAStudy(21, 0, "Close", MAStudy.SIMPLE);
                  var vRSI14 = new RSIStudy(14, "Close");
                  var vBollinger20 = new BollingerStudy(20, "Close", 2);
                  var vLastAlert = -1;

                  //}}EFSWizard_Declarations 27723


                  function preMain() {
                  //{{EFSWizard_Code_PreMain_setPriceBarColor
                  setColorPriceBars(true);
                  //}}EFSWizard_Code_PreMain_setPriceBarColor 3448
                  /**
                  * 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("conditional strategy2");
                  //}}EFSWizard_PreMain 6821

                  }

                  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 (
                  vSMA8.getValue(MAStudy.MA) > vSMA21.getValue(MAStudy.MA) &&
                  vRSI14.getValue(RSIStudy.RSI) > 50 &&
                  ((vBollinger20.getValue(BollingerStudy.UPPER)) - (vBollinger20.getValue(BollingerStudy.LOWER)))>30
                  ) onAction1()
                  //}}EFSWizard_Expression_1 29258

                  //{{EFSWizard_Expression_2
                  else if (
                  vSMA8.getValue(MAStudy.MA) < vSMA21.getValue(MAStudy.MA) &&
                  vRSI14.getValue(RSIStudy.RSI) < 50 &&
                  vBollinger20.getValue(BollingerStudy.UPPER) - vBollinger20.getValue(BollingerStudy.LOWER)>30
                  ) onAction2();
                  //}}EFSWizard_Expression_2 31951

                  //}}EFSWizard_Expressions 82089


                  //{{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() {
                  setPriceBarColor(Color.RGB(0,255,0));
                  if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
                  vLastAlert = 1;
                  }
                  //}}EFSWizard_Action_1 23225

                  //{{EFSWizard_Action_2
                  function onAction2() {
                  setPriceBarColor(Color.RGB(255,0,0));
                  if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
                  vLastAlert = 2;
                  }
                  //}}EFSWizard_Action_2 22409

                  //}}EFSWizard_Actions 68512

                  Comment

                  Working...
                  X