Announcement

Collapse
No announcement yet.

created my strategy in Wizard, backtest doesn't work

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

  • created my strategy in Wizard, backtest doesn't work

    I have created a trading strategy in formula wizard. I am up to the point where I am getting the bars on my chart to be blue when my strategy is bullish, red when my strategy is bearish, and black when it is neutral. I go to the backtester and test this strategy, and it just says calculating for a while, then I try to close the window, and I have to shut down esignal because the program doesn't respond.

    I really want to backtest my strategy. I am thinking there is more coding to be done for the strategy, but I don't know what it is. I even put the "doLong" line in when I want to buy, and "doShort" line in when I want to sell. But apparently, there is more to do.I have read some info in the knowledge base, and I am not figuring out "where to put what" so to speak.

    I know I can source this work to a third party that Esignal is linked with, or any EFS expert for that matter. I want to see if I can complete this without using that option though.
    I appreciate any help you can provide.

  • #2
    JMR6157
    Post the efs and someone may be available to go through it and if necessary offer some guidance.
    Is the efs loaded in a chart when you run the Back Test? Also what version of the software are you running (version and build)?
    Alex

    Comment


    • #3
      image of chart w/strategy

      Here is a chart w/the strategy I write about in my previous post. I may need code to account for the black bars when the system is not in the market. I appreciate any help.


      Comment


      • #4
        Answers to Alex

        Alex,

        I am using 7.9.1.

        Yes, I have my formula loaded in the chart when I am backtesting.

        Jason

        Comment


        • #5
          Jason
          As I suggested in my prior reply you may want to post the efs for someone to be able to offer any guidance
          Alex

          Comment


          • #6
            here is the efs

            In the formula wizard, my first two sets are for entries, my second two sets are for exits. Thank you very much!

            Jason





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


            //{{EFSWizard_Declarations
            var vEMA9 = new MAStudy(9, 0, "Close", MAStudy.EXPONENTIAL);
            var vEMA20_2 = new MAStudy(20, 0, "Close", MAStudy.EXPONENTIAL);
            var vStoch60_26 = new StochStudy(60, 26, 10);
            var vLastAlert = -1;
            //}}EFSWizard_Declarations


            function preMain() {
            //{{EFSWizard_Code_PreMain_setPriceBarColor
            setColorPriceBars(true);
            //}}EFSWizard_Code_PreMain_setPriceBarColor
            /**
            * 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("");
            //}}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 (
            vEMA9.getValue(MAStudy.MA) > vEMA20_2.getValue(MAStudy.MA) &&
            vStoch60_26.getValue(StochStudy.FAST) > vStoch60_26.getValue(StochStudy.SLOW)
            ) onAction1()
            //}}EFSWizard_Expression_1

            //{{EFSWizard_Expression_2
            else if (
            vEMA9.getValue(MAStudy.MA) < vEMA20_2.getValue(MAStudy.MA) &&
            vStoch60_26.getValue(StochStudy.FAST) < vStoch60_26.getValue(StochStudy.SLOW)
            ) onAction2()
            //}}EFSWizard_Expression_2

            //{{EFSWizard_Expression_3
            else if (
            vStoch60_26.getValue(StochStudy.FAST) < vStoch60_26.getValue(StochStudy.SLOW)
            ) onAction3()
            //}}EFSWizard_Expression_3

            //{{EFSWizard_Expression_4
            else if (
            vStoch60_26.getValue(StochStudy.FAST) > vStoch60_26.getValue(StochStudy.SLOW)
            ) onAction4();
            //}}EFSWizard_Expression_4

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

            //{{EFSWizard_Action_2
            function onAction2() {
            setPriceBarColor(Color.RGB(155,0,0));
            Strategy.doShort("", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
            vLastAlert = 2;
            }
            //}}EFSWizard_Action_2

            //{{EFSWizard_Action_3
            function onAction3() {
            Strategy.doSell("", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
            vLastAlert = 3;
            }
            //}}EFSWizard_Action_3

            //{{EFSWizard_Action_4
            function onAction4() {
            Strategy.doCover("", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
            vLastAlert = 4;
            }
            //}}EFSWizard_Action_4

            //}}EFSWizard_Actions

            Comment


            • #7
              Jason
              The way the strategy is laid out causes it to generate a trade on every bar in which the conditions are true.
              Try applying the changes shown in the following images



              Notice that I have added a condition that checks that the strategy is not Long. This is for the entry signal (ie Set1).



              For the exit signal (ie Set3) instead it checks that the strategy is Long.
              Apply the same logic for Set2 and Set4 using isShort()==false and isShort()==true respectively.
              Alex

              Comment


              • #8
                Alex
                Thank you for your suggestions, I made them in the formula wizard. However, the backtest still doesn't work. I try to backtest, and the progress window says "989 bars received" and it keeps saying that until I close the window. Thanks again for your help, what can I do the fix this?

                Comment


                • #9
                  Jason
                  This could be related to the problems that JasonK mentions in this post.
                  Alex

                  Comment


                  • #10
                    OK, thanks for letting me know.

                    Jason

                    Comment


                    • #11
                      Jason
                      In this post you can find the link to an updated version that resolves the issue you are having
                      Alex

                      Comment


                      • #12
                        Nice! Thank you.

                        To have the most realistic entries and exits, is there a setting (e.g. open nextbar, close thisbar, etc.) you recommend?

                        Jason

                        Comment


                        • #13
                          Jason
                          You would use Strategy.MARKET and Strategy.THISBAR only if you are evaluating the conditions at the prior bar else you would probably want to use Strategy.CLOSE and Strategy.THISBAR.
                          Alex

                          Comment

                          Working...
                          X