Announcement

Collapse
No announcement yet.

Back Testing

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Back Testing

    I´m lookimg for the formula for a backtest with
    the RMI. (3,8)

    1. if RMI > 80 go LONG
    2. if RMI < 20 go SHORT

    Can someone help me, how I provide this formula??

    Thanks

  • #2
    tanita

    I found two versions of the RMI indicator both coded by TS Support and available at their site and presumably in their group at FileShare.
    Given that you were indicating two variables I took their alternative version of the RMI (which allows for that) and added the strategy as per your message.
    The system goes long if RMI moves above 80, sells to close the long if RMI comes back below 80, goes short if RMI moves under 20 and covers shorts if it goes back above 20.
    The entries for the strategy are on the Open of the bar following the one that generates the signal.
    The enclosed image shows you how the indicator should appear.
    Hope this helps

    Alex

    Attached Files

    Comment


    • #3
      tanita

      Here is a variant of the same strategy.
      In this version the Buy and Sell are on a breakout of the high or low of the bar that generates the signal.
      As of now the breakout is set for one tick of ES (0.25) but can be changed in Lines 94 and 99 of the formula to suit your needs.

      Alex
      Attached Files

      Comment


      • #4
        Alex

        Hi,
        this formula ( test-rmi2-market) was exactly the correct one.

        Cordial thanks and a nice day

        Comment


        • #5
          Backtest Williams%R

          Hi,
          I´m looking for the formula for a backtest with
          the Williams % R(14)

          1. if Willi < -20, go LONG
          2. if Willi < -80, go SHORT

          Can someone help me, how I provide this formula??
          Thanks and a nice day

          Comment


          • #6
            tanita
            The attached efs should do what you are asking
            Alex
            Attached Files

            Comment


            • #7
              Backtest/ efs

              Hi Alex,
              thanks a lot.

              Is there the possibility of a combination of three Indis as baking
              test/ efs??

              1. Go Long if (only)

              Williams %R > -20 + Aroon up = 100 + RMI > 80

              2. Go Short if (only)

              Williams %R < -80 + Aroon down = 100 + RMI < 20

              Thanks for your help and assistence

              Comment


              • #8
                tanita
                It is possible, but setting up the formula to calculate all three indicators and/or cross reference them is beyond what I am available to do at this time.
                Alex

                Comment


                • #9
                  Backtest Time Template

                  Hi,
                  in the baking test time Template cannot be adjusted and
                  computed the daily end. (Intradaytrading!)

                  If one accomplishes a week test or a monthly test, the program further calculates and takes the time of in the evening to the next tomorrow as new order!

                  Comment


                  • #10
                    tanita

                    If you are saying that the Strategy Analyzer (ie Back Testing) does not close trades at the end of each day when intraday trading then that is correct. You need to specify that in the efs.
                    There are a number of examples that have been posted in this and other forums.
                    I agree though that it would be preferable if there were some sort of built-in routine that one could easily call when setting up the strategy.

                    I am not sure I fully understand your second point.

                    Alex

                    Comment


                    • #11
                      Back Test Times

                      Hi, Alex,
                      it is difficult to find out.

                      My trading houres are: 9:00 -19:00 and i start always with a new day on the same time.

                      A overnight position does not exist.

                      Nice and sonny day

                      Comment


                      • #12
                        tanita
                        Below are the links to a few threads that might provide some insight.
                        Alex





                        Note: In the last thread there is a formula which contains a section that closes trades at the end of a session
                        Last edited by ACM; 03-29-2003, 11:10 AM.

                        Comment


                        • #13
                          linkproblem

                          if i try to follow the 3rd link, because i need the codesample for close the trade on the daysession end, i get the following message:

                          vBulletin Message
                          You do not have permission to access this page. This could be due to one of several reasons:
                          You do not have permission to access the page that you were trying to. Are you trying to edit someone else's post or trying to access administrative features? Check that you are allowed to perform this action in the Forum Rules.
                          If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
                          Logged in user: thedon [logout]

                          could somebody help me ?
                          thanx

                          Comment


                          • #14
                            thedon
                            That link is to the Beta Forum for which you need to be registered.
                            Anyhow I just lifted the formula off that thread and am copying it here.
                            Alex

                            PHP Code:
                            // works well on 85T with Profit = 1.5 and stop = 2.25

                            var nsignal 0
                            var 
                            newTrade 0;
                            var 
                            prevSAR =0;
                            var 
                            study = new StochStudy(6,2,2);

                            var 
                            nTradeEntryPrice
                            var 
                            ProfitTarget1 1.5;
                            var 
                            StopLoss1 1.5;
                            var 
                            ProfitTarget2 0.5;
                            var 
                            StopLoss2 1.5;
                            var 
                            Stop 0;
                            var 
                            Profit 0;

                            function 
                            preMain() {
                            setPriceStudy(true);
                            setStudyTitle("SAR Strategy");
                            }

                            function 
                            main() {
                            var 
                            vHL high(-1) - low(-1);
                            var 
                            vVar vHL 0.5// used for DrawTextRelative
                            var vAddVar vVar 0.5// Used for DrawTextRelative 
                            var vFast study.getValue(StochStudy.FAST0, -2);
                            var 
                            vSlow study.getValue(StochStudy.SLOW0, -2); 

                            var 
                            SAR callFunction("Downloads/SAR.efs","main",3.4,20);

                            if(
                            SAR == null || vFast == null || vSlow == null) return;

                            if ((
                            Strategy.isInTrade() == true) && (newTrade == 1)) 
                            {
                            nTradeEntryPrice open(); 
                            newTrade 0// Turn off NEW TRADE switch
                            }

                            Strategy.doSell("LongPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice 1));

                            // This portion of the code identifies if our profit target has been reached and exits our trades.

                            if ((Strategy.isInTrade() == true) && (Strategy.isShort() == true))
                            // Check if the profit target has been reached/breached
                            if (low() <= (nTradeEntryPrice Profit)) 
                            {
                            Strategy.doCover("ShortPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Profit));}

                            if (
                            high() >= (nTradeEntryPrice Stop)) 
                            {
                            Strategy.doCover("ShortSL Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Stop));}
                            }

                            if ((
                            Strategy.isInTrade() == true) && (Strategy.isLong() == true)) 
                            // Check if the profit target has been reached/breached
                            if (high() >= (nTradeEntryPrice Profit)) // Profit Target Met Execute Cover order.
                            {Strategy.doSell("LongPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Profit));}

                            if (
                            low() <= (nTradeEntryPrice Stop)) // Profit Target Met Execute Cover order.
                            {Strategy.doSell("LongSL Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Stop));}

                            }

                            //Trailing Stops
                            if ((Strategy.isInTrade() == true) && (Strategy.isShort() == true)) {Stop high(-1) + 0.5;}
                            if ((
                            Strategy.isInTrade() == true) && (Strategy.isLong() == true)) {Stop low(-1) - 0.5;}

                            if ((
                            SAR close()) && (prevSAR close(-1))) 
                            newTrade 1// New Trade Trigger
                            nsignal = +1// Buy Signal
                            Stop StopLoss1;
                            Profit ProfitTarget1;
                            }

                            if ( (
                            Strategy.isInTrade() == false) && (SAR close()) && ((vSlow[1] < vSlow[0]) && (vSlow[1] <= 38)) )
                            newTrade 1// New Trade Trigger
                            nsignal = +1// Buy Signal
                            Stop StopLoss2;
                            Profit ProfitTarget2;
                            }

                            if ((
                            SAR close()) && (prevSAR close(-1)))
                            newTrade 1// New Trade Trigger
                            nsignal = -1// Sell Signal
                            Stop StopLoss1;
                            Profit ProfitTarget1;
                            }

                            if( (
                            Strategy.isInTrade() == false) && (SAR close()) && ((vSlow[0] < vSlow[1]) && (vSlow[1] >= 62)) )
                            newTrade 1// New Trade Trigger
                            nsignal = -1// Sell Signal
                            Stop StopLoss2;
                            Profit ProfitTarget2;
                            }

                            prevSAR SAR;

                            // Execute Trades ONLY if nNewTrade is triggered
                            if ((newTrade == 1) && 
                            ((
                            getHour() >= 18) && ((getHour() < 21))) 

                            { if (
                            Strategy.isInTrade() == true// reverse current trade position
                            {if ((nsignal 0) && (Strategy.isShort() == true)) {Strategy.doCover("Exit Short"Strategy.MARKETStrategy.NEXTBAR);}
                            if ((
                            nsignal 0) && (Strategy.isLong() == true)) {Strategy.doSell("Exit Long"Strategy.MARKETStrategy.NEXTBAR);}


                            if ((
                            nsignal 0)) 
                            {
                            Strategy.doLong("Long"Strategy.MARKETStrategy.NEXTBAR);
                            drawShapeRelative(0low() - vVarShape.UPARROW""Color.limenull,"buyShp" getValue("time"));
                            drawTextRelative(0low() - (vVar vAddVar), "B"Color.blackColor.lime,Text.BOLD Text.ONTOPnullnull"buyTxt" getValue("time"));
                            }
                            if ((
                            nsignal 0)) 
                            {
                            Strategy.doShort("Short"Strategy.MARKETStrategy.NEXTBAR);
                            drawShapeRelative(0high() + vVarShape.DOWNARROW""Color.rednull,"sellShp" getValue("time"));
                            drawTextRelative(0high() + (vVar vAddVar), "S"Color.blackColor.red,Text.BOTTOM Text.BOLD Text.ONTOPnullnull"buyTxt" getValue("time")); 
                            }
                            nsignal 0
                            // END EXECUTE NEW TRADE


                            if (getHour() == 21 && getMinute() == 05)
                            // Close out at this time each day
                            if (Strategy.isShort())
                            {
                            Strategy.doCover("EOD exit"Strategy.MARKETStrategy.NEXTBAR);
                            nsignal 0;}
                            else if (
                            Strategy.isLong())
                            {
                            Strategy.doSell("EOD exit"Strategy.MARKETStrategy.NEXTBAR);
                            nsignal 0;}

                            return ;

                            Last edited by ACM; 04-03-2003, 10:31 AM.

                            Comment


                            • #15
                              Hi Alex,

                              thank you verry much !
                              i think this should help ;-)

                              Alex

                              Comment

                              Working...
                              X