Investor/RT
Tutorials
Backtest Tutorial by F_Trader (User Submitted)
Revision 1.00 / February 26, 2003

 

Click here to download Word (.doc) Document

 

INTRODUCTION:

 

These pages are intended to help IRT users making their debut with the backtesting feature. Basic knowledge on RTL language and IRT syntax for Trading Signals and custom indicators will of course help. Anyhow, this document was not written to replace the current Linnsoft documentation that you may find there:

 

http://www.linnsoft.com/tour/tradingSystems.htm

http://www.linnsoft.com/tutorials/ruleTesting.htm

 

but is mainly intended to bridge the GAP between :

 

š      how one manage, in his realtime daytrading activities, the signals which can be generated by his own indicators on his charts

AND

 

š      the best way to build a full trading systems from these indicators (and implement money management rules) with the very powerful tools available in the RTL programming language and the IRT backtesting features.

 

 

Finally, being a mainly E-minis trader located in Europe, you will notice in my scripts that:

  • the main US trading session runs here from 1530 to 2200
  • all trading systems examples are based on a 5 minute timeframe, the default trading size being two ES contracts.

 

Of course, all explanations can be easily adapted for systems based on daily bars or on stocks…

 

I really hope you will enjoy this Tutorial which gathers together most of my backtesting experience with IRT for the past year.

 

All scripts here should be run with IRT version 5.9.7 or later.

 

Do not hesitate to contact me for question on this paper, or for reporting possible tipping errors or inconsistencies by email at f_trader02@yahoo.fr, using the Linnsoft Yahoo group or thru the #Linnsoft chatroom on the OTHERNET IRC server.

 

 

Happy Backtesting

 

Eddy

 

 

PS: please consider this very first version as a DRAFT / Check for any new revision of this document which will be most likely advertised on the Yahoo group or on www.linnsoft.com


 _ACTUAL TABLE OF CONTENT__ 

 

 

CHAPTER 1: Basic guidelines for writing entry and exit trading signals  

 

1.1)      Distinction between End Of Bar (EOB) and Intra-Bar (INB) signals

 

1.2)      Market order type and slippage considerations for EOB and INB signals

 

1.3)      Adding a “filter” to our entry rules

 

1.4)      Managing reverse rules

 

1.5)      Tips for getting EOB / INB  signals markers on your chart and about the equity curve charts

 

1.6)        Detailed scripts of the trading systems discussed in Chapter 1

 

 

CHAPTER 2: How to add Money Management rules to an IRT trading system

 

2.1) Using an EOB approach for money management rules: a logical choice

 

2.2) Definition of the Money Management V# variables.

 

2.3) The Money Management (MM) rules explained step by step

 

2.4) How to simplify the “maintenance” works around backtest or how to use exactly the same single trading system for testing different strategies

 

2.5) Detailed scripts of the trading systems discussed in Chapter 2

 

 

 

_VIRTUAL ADDITIONAL TABLE OF CONTENT__ 

 

 

For information only, here are the chapters, NOT yet on paper, but which could get out of my head one day and follow the existing chapters 1 and 2

 

3) Custom reporting with the NOTE Token

This NOTE token allows you to show any V# variable value in the detailed report file: you may use it to build a fully customize report

 

4) Getting your backtest rules in realtime on your charts

or how to get live on your charts you’re the same entry/exit/MM signals than the one you get in your backtest (without running any backtest ..)

 

5) Managing multi-periodicity (and even multi-instrument) signals  

This issue is already discussed a bit in section 1.5

 

 

6) Optimisation of your trading system parameters

IRT allows you to automatically find for example the Initial Stop level producing the highest overall profit : using the scheduler features, and adequate V variables setting, you may implementing very easily this hidden optimisation feature on any existing trading systems

 

7) Max Favorable / Adversary excursion and Intra-trade Drawdown analysis

Detailed MFE/MAE analysis and reporting for all backtested trades can be achieved using some V# variables

 

 


 

 

 

 

CHAPTER 1 : Basic guidelines for writing entry and exit trading signals  

 

We will start explaining here the distinction between:

A) an “End Of Bar” (or EOB) Signal

B) an “Intra-Bar” (or INB) Signal

and the impact of this essential choice on the way you may write ALL your trading rules whatever their type : i.e. entry signals, filters, profit taking rules, stop loss rules, etc

 

In fact, when designing a trading system, the first step is to check that you have a coherent approach between:

š      your trading style, i.e. how you manage your signals in realtime

š      and the way you intend to transcript them for backtesting purpose

 

In order to write coherent trading rules and not cheat with your backtest (ie enter a signal at a given time using “future” data), it is essential that you understand all nuances between EOB and INB signals. By experience, I guarantee you that the main pitfall before getting “realistic” backtest results are here...

 

You will find that it might be interesting to open twice this document so that you may follow at the same time how the systems are building, and how the final result (ie IRT text transcript of all the rules) looks like. These transcripts are located at the end of each chapter.


1.1) the distinctions between EOB and INB signal

 

We will consider in this chapter a basic breakout system based on 5 minute bar chart.

In this system, you enter a long position when there is a breakout of the Highest High of the 10 previous bars, and you exit it at the break of the Lowest Low for the 7 previous bars..

 


A) End of Bar Signal (EOB)

 

If your system is : wait for the first CLOSE of a given bar to be
higher than the highest high of the 10 preceding bars to go long,
then your entry rule will have following logic :

If CL > STAT.1 Then BUY 2 at Close Price


with  STAT = Maximum Close for Preceding 10 Bars

Of course, you need to use STAT.1 in this trading signal in order to simulate the highest high of the 10 PREVIOUS bar and exclude the high of the current tested bar

Note: Since version 5.9.7, you could also use the syntax: CL > MAX (HI.1, 10)

In this case, what is important is that you wait UNTIL the end of the 5 min bar to make a decision about entering a trade, because your rule is : wait that the CLOSE of the current bar breaks the highest high of the 10 previous bar (by the way, this particular value is known since the start of the current 5 minute bar)

 

ie with EOB signals, you don’t care at all about what the market could do during 5 minute : there could be 1000’s of trades (which will be compacted into the Open / Low and High information), you will be using only ONE trade data to take a decision : the CLOSE of the bar

 

The corresponding trading system, incl. Filter rules (as explained later in section 1.3) will be named REF_SYSTEM_A_EOB and its scripts, as other in this chapter is available in section 1.6.1)

 

 

 

B) Intra-Bar Signal (INB)

 

In this case, your entry signal can be described as:

As soon as there is one trade done at a value higher than the previous 10 bars high, you enter the trade.

While trading in realtime with this approach, this requires you (or trading platform) monitor all the trades as they might appear in a “Time and sales” windows for example, because you need only one tick i.e. one trade with the adequate price to trigger your entry.

 

Anyhow, in the backtest, your entry price will be the Highest High of the previous 10 bar. This value is not listed by default in the “Rule Price” window, so you need to store it using a V variable.

In IRT syntax, this will be done thru a SET statement like SET(V#2,STAT.1) which will appear in a Trading signal at the top of the rules list (the STAT token has the same setting than in A))

We will name it Store_Bkout_value and it will be associated to a NONE rule (i.e. "no action" rule)

 

Please note that you will need to rename the STAT token in the Trading signals definition because he will be used several time.

This way, the value will be updated at every backtest iteration, i.e. for every new 5 minute bar.

 

The entry trading signal associated to the BUY action will be then:

If HI > V#2 Then BUY 2 at Value V#2 Price

For more: see the script of the system named REF_SYSTEM_A_INB in 1.6.2)

 

Note:

Do not forget to go to the “Set Up / Preferences / User variables” menu to give a title to this V variable.

 

 

1.2) Market order type and slippage consideration for EOB and INB signals

 

OK, this part is not fully linked to IRT issue but it helps understand the difference between EOB and INB signals

 

 

A) End of Bar Signal

 

In such a system, you do not know “in advance” what will be your entry price as long as the 5 minute bar is completed (of course, you do try to enter on the CLOSE of the bar)

So basically, if your system trigger when the CL data is printed, you would enter the market as soon as possible, typically with a market order, i.e. you will experience slippage. Of course, this impact of the slippage (let’s say one or two ticks for futures) on the Trade PL will be relatively less if you are running a longer timeframe... (because then your average profit is larger..)

Indeed, it might take you between 5 and 30 seconds to send you order thru your broker platform, not so an issue if you are working with 30 minute bars, but this is a big issue if your are working with 1 minute bars…

 

 

B) Intra-Bar Signal

 

In this case, you know “in advance” (i.e. as soon as a 5 minute period starts) what could be your entry price for both a long or short trade. But, at the opposite of EOB signals, the signal could trigger (in realtime) at any time, not only at the completion of the 5 minute bars. But knowing in advance the possible entry price allows you to use pre-programmed limit orders (for both long and short entry): i.e.

you will be updating the corresponding values of the resting go long/short orders every 5 minutes, at the start of every new bar… Such an operation could take few seconds, so in this case:

š      either you may experienced slippage is the breakout occur just at the start of the bar (because you don’t have updated yet the value of your resting limit order)

š      either, and this is the case most of the time, you won’t experienced any slippage at all, i.e. your limit order will be filled at the exact price

 

 
C) The bid/ask story or how to make sure that the “backtest fill” is a realistic one

 

Personally, I trade the S&P E mini which always have (during the day session) a single tick (i.e. 0.25 point) difference between the ask and the bid.

However, having a bid/ask at 835 / 835.25 and a buy limit order at 835.25 do NOT guarantee you a fill.

 

This is why I would write, in such a case, my entry rule as

HI > STAT.1   

and NOT as       HI > = STAT.1

Indeed, I want to make sure that the limit order (I simulated in the backtest) would be filled.

 

There will be more example of this conservative approach later in this tutorial. The main idea is that I prefer to have a pessimistic backtest result than an optimistic one…
1.3) Adding a “filter” to our entry rules

 

Adding Filter provides a very good illustration to the difference between EOB and INB signals. Let’s consider the typical ADX filter, i.e. a breakout will be only traded if the ADX is above 25 AND the ADX is increasing

 

A) For EOB rules

In such system, you enter a trade as soon as the signal is triggered, i.e. when the 5 minute bar is completed. So you may use all the price data of the current bar in your filter calculation, including of course the CLOSE

The entry signal for a long signal would be then:

 

If ( CL > STAT.1  AND  ADX > 25  AND  ADX > ADX.1) Then BUY 2 at Close Price

 

B) Intra-Bar rules

In this case, as your signal may trigger as soon as the new bar starts to form, it is not possible to use the current close in the filter calculation

If this is not clear yet in your mind, remember that the IRT backtesting makes calculation ONCE at the end of every time frame (here 5 minutes), so if you simulate an entry during the current bar, you need to limit your data until the previous Bar data (i.e. CL.1 or ADX.1), so that IRT does not use the CLOSE which will historically be printed after your possible trade entry time.

 

This is why the entry signal for a long trade would be then be here:

 

If (HI > V#2 and ADX.1 > 25 and ADX.1 > ADX.2) Then BUY 2 at Value V#2 Price

 

(with V#2 being set as STAT.1)

 

WARNING: The rules:   If (HI > V#2 and ADX > 25) Then BUY 2 at Value V#2 Price is clearly incorrect because “future” data is used to take a decision in the past.

 

By the way, IRT or (any other trading software) doesn't have sufficient logic to warn the user with “an error message”. So always verify the rules logic behind any backtesting report producing some extraordinary results…

 

Note:

For INB and EOB, I have used exactly the same filter rule for both LNG and SHT sides, so I could have basically have used a unique trading signal name : of course, there are usually different, so I'll keep naming them __LNG_FILTER and __SHT_FILTER

 

C) Adding Filter as CONFIRM rules

As soon as your trading system starts to be a bit complex, I would recommend to have a modular approach, i.e. for example, you may include your filter with a CONFIRM rules, just before the actual BUY or SELL actions in the list of trading rules.

This is the way the script features at the end of this chapter are structured.

Indeed, such CONFIRM rules will greatly improve:

1)    the legibility of the structure of the trading rules

2)    the execution times of your backtest (as the possibly complex entry rules calculation will be only done IF the filter rules returns true)

3)    allow you to use the same filter rules in different trading systems

 

Please note that the most common filter will be in fact a TIME FILTER

Let’s say that you will not enter trade on the first or last 10 minutes of the daysession, you could write it in a Trading signal as: (TIME > 1540) AND (TIME<2150)

You will notice that I do prefer write this rule as:   (TIME > 1540)*(TIME<2150) > 0

because it look like such approach results in quicker calculation

 

For example if you want to enter a trade only on the first or last hour, you may write the corresponding signals as:

(TIME > 1530 AND TIME<1630)   OR   (TIME > 2100 AND TIME < 2200)

or as : (  (TIME > 1530)*(TIME<1630)  + (TIME > 2100)*(TIME < 2200)  ) > 0

 

PS : As I never hold any position overnight, all my trading systems will include a Market close rule (MKT_CL), i.e. exit all position when the trading signal TIME=2200 returns true…

 

Do not forget to use such Time filter if you have 24 hours data available (like it is the case for ES), otherwise you will end up triggering trade at 3 in the night: indeed the IRT backtesting data will be based on the default session of the instrument tested


 

 

1.4) Managing reverse rules

 

OK, before investigating the implementation of money management rules, we need to see how to manage reverse rules, which can be a bit tricky when combined with filter rules… You might think: reverse rules are easy to master!

I will answer that this might be the second major sources of mistakes after the confusion between EOB and INB signals.

By the way, please note that following comments are fully valid for both EOB and INB type of rules

 

A)    With no dedicated filters rules

 

Let’s start with a system having “NO filter rules” and a set of symmetrical rules: i.e. the exit rules of a Short trade ALWAYS trigger the start of a long position

 

In our example, this would mean that breakout period for entering and exiting a position are the same (let’s say 10 bars). SO the LNG_EXIT_SIG_EOB rule is still:

CL < STAT.1 but with STAT = Minimum of the Low of 10 preceding bars (instead of 7 bars)

 

In this case, implementing the reverse rules is quite an easy task:

 

For exiting a long position, you just replace SELL by a REVERSE-SELL & SELL SHORT action

For exiting a short position, you just replace COVERSHORT by a REVERSE-COVERSHORT & BUY action

So the order of the rules could be as follow:

 

BUY rule

SELL rule

REVERSE-SELL & SELL SHORT

REVERSE-COVERSHORT & BUY action

 

In IRT, these REVERSE rules allow to Exit a long position and Enter a short position on the same bar! We will tell more on that later, in section 2.3

 

 

B) With a filter rule prior to the entry signal

 

Let’s consider now our breakout system having the same 10 bar period, BUT with some a filter for initiating a NEW position (short or Long)

 

Here it is just a bit trickier. Indeed, in this case, when you get your signal for exiting a Long Position, you must make check the “filter” status to know if this breakout of the 10 previous bar results in:

 

š      Exiting a Long position and remaining flat (filter status = false)

š      Exiting a Long position and entering a Short (filter status = true)

 

In this case, you just need to write in the following order (let’s consider first only the LONG side rules before mixing both SHORT and LONG positions)

 

LNG FILTER CONFIRM rule

BUY rule

SHT REV FILTER CONFIRM rule

REVERSE-SELL & SELL SHORT rule

SELL rule

 

What is important to understand is that you are managing here TWO exit signals, and that you absolutely need to put your Reverse Rules Statement (which will be activated if the associated Filter CONFIRM rule returns true) BEFORE the usual exit rules statement… The order in which you place your trading actions on the rules list is vital in IRT.


 

Please note as well that an SHT_FILTER_EOB_REV for example will be almost identical to the SHT_FILTER_EOB one  except that we will add to it a check for “POS_STATE=1”, i.e. this filter can only returns true in a REVERSE situation, i.e. when a LONG trade is ongoing

 

Ok, this might sound a bit complex for a implementing a reverse rules, but remind here that we are managing in fact two exit signals.

Of course, one could decrease the number of rules by incorporating the “Filter rules” within the actual SELL and REVERSE-SELL & SELL SHORT rules.

But I really prefer this modular approach and use of CONFIRM rules.

There are further advantages that will appear only in the coming chapters..

 

 

For the Short side, the set of rules will be:

           

SHT FILTER CONFIRM rule

SELL SHORT rule

LNG REV FILTER CONFIRM rule

REVERSE-COVERSHORT & BUY rule

COVERSHORT rule

 

And if we combined both long and short rules:

 

LNG FILTER CONFIRM rule

BUY rule

SHT FILTER CONFIRM rule

SELL SHORT rule

LNG REV FILTER CONFIRM rule

REVERSE-COVERSHORT & BUY rule

COVERSHORT rule

SHT REV FILTER CONFIRM rule

REVERSE-SELL & SELL SHORT rule

SELL rule

 

You have noticed that rules for initiating new trades are of course situated before the exit signals.

 

In EOB type of approach, you usually won’t have at the Close both Short and Long trades triggering at the same time (otherwise, recheck your rules logic!!), so the respective order between the SHT and LNG rules (within the ENTRY or EXIT set of rules) doesn’t matter.

 

HOWEVER, with the INB approach, it is fully possible that the same bar trigger a BUY and SELL actions (imagine a very wide outside bars breaking at the same time the previous 10 bars Low and Highs). In this quite rare situation, there is no magic, with the above set of rules, the BUY signal would be triggered first.

Anyhow, as there is no way to know if the HI or LO of a bar occurred first, it is impossible to simulate correctly in this case what could happen in realtime…

Moreover, with our present set of rules, what would happen is that the trade will be then systematically closed on the same bar, resulting in a negative PL…

At least, this will not “over-optimize” our system performance…

So I consider these point to be really a very minor inconvenient compared to the benefits of an INB approach for simulating breakouts…

 

Please remember as well, there is many ways to manage Filter and Reverse rules in IRT. I am just showing you one possible approach! If you select another approach, just be careful to have a set of coherent rules…

 

I have attached in 1.6.3 the full script for an EOB system including Filter and Reverse rules

 

 

 


 

1.5) Tips for getting EOB / INB signals markers on your chart and about the equity curve chart

 

We will be discussing here quickly charting issue related to:

 

A) Entry and exit trade signals markers

 

Breakout types of entry are the easy one to program using a INB method. What is very nice with such approach is that you do not have any blinking signals on your chart.

Here is what I mean:

Let’s say that I have a Signal marker associated to the rule:

HI > STAT.1

In this case, as soon as the marker appears once during the life of a 5 minute bars, it will remains: indeed, the High can only goes higher (except may be in case of bad ticks, which are really rare with E-minis)…

 

On the other hand, let's consider the EOB rules:

CL > STAT.1

Depending on the last trade value, during the building of the 5 min bars, you could have a “blinking marker” if the ongoing trades “oscillate” successively above and below the trigger level. This is a good indication a trade could be trigger soon, when the bar is completed, but is quite annoying at the end of the day if you follow this marker to actually pull the trigger on your broker platform.

 

My tip is the following in case of EOB entry signals:

 

1)    I would use a color marker BELOW the chart for showing different colors depending on the status of the CL > STAT.1 statement

 

2)    I use on the chart a signal marker, but it is :

š      associated to the signal CL.1 > STAT.2

š      the marker is shifted one bar on the left

š      and is linked to a given wav sound

 

This way, if the signal triggers indeed at the close of the bar, the marker you then appears ONCE on the chart (will not blink of course) and a sound alarm will tell me that I have a CONFIRMED buy signal.

 

There is much more to say on this charting and markers issue. Indeed, the problem with using the embedded “Chart rules” features in IRT is that it does not take into account the preceding CONFIRM rules. So, on my side, I will use another approach.

I have already detailed it a bit in the Yahoo forum:

You may have a look for example at this particular message:

http://groups.yahoo.com/group/LinnSoft/message/5601

which illustrate a very interesting use of the powerful Signal Statistics token (SSTAT)

 

More on that may be one day in a possible chapter 4

 

 

B) the Equity curve Chart :

 

OK, there is a lot to say here as well but I will try to keep it to the essential:

The equity curve information is stored in the $REF_SYSTEM_A_EOB instrument which will be only generated if you check the box “Account Balance charts” of the “Setup backtest” window.

 

If you have an intraday system (based on 5 minute bars) and if you want to have a nice equity curve of the past 2 years (if this is your backtest period) fitting on your screen width (with no scrolling), you need to create a chart with

š      a style being continuous line

š      a low pixel per bar set up(1 or 2)

š      a periodicity typically equal to your day session duration in minutes (i.e. like 405 minutes)

š      a gridline color being the same than your background color (this is require to make the daily start of session vertical line, which will be highly compacted with a 405 min. periodicity) invisible

 

 

Then, I recommend to add some vertical reference line at given date (like at every year or month start).

This way, you get a nice chart dedicated for equity curve AND you should save this charts as being the default one for the instrument $REF_SYSTEM_A_EOB. This way, each time your backtest is finished, this chart will automatically pop up (instead of the standard default chart)

 

 

Below the equity curve, I would suggest to chart the following information in separate pane:

š      The ongoing Drawdown

This is showing you at a given time the current drawdown (on a daily basis if your periodicity is equal to the daysession duration): this curve can be obtained using a (quite simple) custom indicator equal to “STAT – CL” with STAT being the “Maximum Close” since a fixed date (i.e. the start date of your backtesting period)

š      The instrument data

 

Please note that the equity curve is an instrument like any other, so it is possible to apply to it any kind of technical indicators, including custom indicators…

 

The final result could look like the following screenshot

 

 

 

1.6) Detailed scripts of the trading systems discussed in Chapter 1

Before going further, here the transcript of trading system with Long and Short rules and filters, for both an EOB and INB approach, and with all rules mentioned before...

 

You will notice that, for legibility purpose, all my Trading signals names can be cuts in 3 part

 

First part is either __LNG / __SHT / __L_S meaning this is either a dedicated LONG / SHT rules or a rules common to both type.

It is generally followed by the type of action, i.e. ENTRY / Exit or FILTER

Finally, if the trading signal is specifically linked to an EOB/INB approach or used for a Reverse rules, you will find back these 3 Letters at the end of the name

 

PS: there is unfortunately no IMPORT facility within IRT for trading systems. So, if you want to copy this system into your own IRT, you will need to create again with “copy and paste” the individual trading signals and then create the successive rules...

 

 

1.6.1) End Of Bar Basic system with FILTER rules:

                        

 


 

Detailed Report: REF_SYSTEM_A_EOB

 

RULE 1: 5 Minutes: If __LNG_FILTER_EOB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 2: 5 Minutes: If __LNG_ENTRY_SIG_EOB then BUY 2 at Close price

SIGNAL=__LNG_ENTRY_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 3: 5 Minutes: If __SHT_FILTER_EOB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 4: 5 Minutes: If __SHT_ENTRY_SIG_EOB then SELL SHORT 2 at Close price

SIGNAL=__SHT_ENTRY_SIG_EOB: CL < STATLO.1

ELEM=CL:Close

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

 

RULE 5: 5 Minutes: If __LNG_Exit_SIG_EOB then SELL 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L7

ELEM=CL:Close

 

RULE 6: 5 Minutes: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 7: 5 Minutes: If __SHT_Exit_SIG_EOB then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H7

 

RULE 8: 5 Minutes: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=EXIT_SIGNAL:Custom Indicator:CI:_CI__Exit_Signal_BT[Scan]

ELEM=TIME:Backtest Time (hhmm)


 

1.6.2) Intra-Bar Basic system with FILTER rules:

 

 

 

 


Detailed Report: REF_SYSTEM_A_INB

 

RULE 1: 5 Minutes: If __L_S_Store_Bkout_value then NO ACTION

SIGNAL=__L_S_Store_Bkout_value: SET(V#2,STATHI.1) and SET(V#3,STATLO.1) and SET(V#4,STAT_HI.1) and SET(V#5,STAT_LO.1)

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=STAT_HI:Statistics:STAT[Scan] MAX H7

ELEM=STAT_LO:Statistics:STAT[Scan] MIN L7

ELEM=V#2:Highest High prev 10 bars

ELEM=V#3:Lowest Low prev 10 bars

ELEM=V#4:Highest High prev 7 bars

ELEM=V#5:Lowest Low prev 7 bars

 

RULE 2: 5 Minutes: If __LNG_FILTER_INB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_INB: (TIME>1540)*(TIME<2150)*(ADX.1>25)*(ADX.1<ADX.2) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 3: 5 Minutes: If __LNG_ENTRY_SIG_INB then BUY 2 at Value V#2 price

SIGNAL=__LNG_ENTRY_SIG_INB: HI>V#2

ELEM=HI:High

ELEM=V#2:Highest High prev 10 bars

 

RULE 4: 5 Minutes: If __SHT_FILTER_INB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_INB: (TIME>1540)*(TIME<2150)*(ADX.1>25)*(ADX.1<ADX.2) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 5: 5 Minutes: If __SHT_ENTRY_SIG_INB then SELL SHORT 2 at Value V#3 price

SIGNAL=__SHT_ENTRY_SIG_INB: LO<V#3

ELEM=LO:Low

ELEM=V#3:Lowest Low prev 10 bars

 

RULE 6: 5 Minutes: If __LNG_Exit_SIG_INB then SELL 2 at Value V#5 price

SIGNAL=__LNG_Exit_SIG_INB: LO < V#5

ELEM=LO:Low

ELEM=V#5:Lowest Low prev 7 bars

 

RULE 7: 5 Minutes: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 8: 5 Minutes: If __SHT_Exit_SIG_INB then COVER SHORT 2 at Value V#4 price

SIGNAL=__SHT_Exit_SIG_INB: HI > V#4

ELEM=HI:High

ELEM=V#4:Highest High prev 7 bars

 

RULE 9: 5 Minutes: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)


1.6.3) End Of Bar Basic system with FILTER and REVERSE rules :

 

 

 

 

 

 

Detailed Report: REF_SYSTEM_A_EOB_REV

 

Be careful : with REVERSE signals, I have changed the parameters of STAT(from 7 to 10) for the SHT & LNG EXIT signals

 

RULE 1: 5 Minutes: If __LNG_FILTER_EOB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 2: 5 Minutes: If __LNG_ENTRY_SIG_EOB then BUY 2 at Close price

SIGNAL=__LNG_ENTRY_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 3: 5 Minutes: If __SHT_FILTER_EOB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 4: 5 Minutes: If __SHT_ENTRY_SIG_EOB then SELL SHORT 2 at Close price

SIGNAL=__SHT_ENTRY_SIG_EOB: CL < STATLO.1

ELEM=CL:Close

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

 

RULE 5: 5 Minutes: If __SHT_FILTER_EOB_REV then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB_REV: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1)*(POS_STATE=1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 6: 5 Minutes: If __LNG_Exit_SIG_EOB then REVERSE-SELL & SELL SHORT 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=CL:Close

 

RULE 7: 5 Minutes: If __LNG_Exit_SIG_EOB then SELL 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=CL:Close

 

RULE 8: 5 Minutes: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 9: 5 Minutes: If __LNG_FILTER_EOB_REV then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB_REV: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1)*(POS_STATE=2) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 10: 5 Minutes: If __SHT_Exit_SIG_EOB then REVERSE-COVER & BUY 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 11: 5 Minutes: If __SHT_Exit_SIG_EOB then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 12: 5 Minutes: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

 

 


 

 

 

CONCLUSION Chapter 1 :

 

Both EOB and INB approaches do have advantages and inconvenient, even if EOB produces clearly easier rules to manage. Of course, it is always possible to “mix” them in a trading system, i.e. using INB rules for entry and EOB rules for exit. For example, On he coming chapter, we will see in the next Chapter that the Money management rules are very good client for INB rules…

However, most of the time, you don’t have the choice: you need to go for an EOB type of rules for the Entry and Exits signals because your decision is based on technical indicators using the close data.

 

Let’s consider a system based on the crossing of a two moving averages like a 20 period MA and a 7 period MA.

 

Of course, in realtime, you could say: I enter a trade as soon as “I see” a MA crossing on a 5 minute charts (i.e. you do not wait the Close of the current 5 min bar), but you will have no way to model that on a backtest using 5 minute bars!!!

To do so, you would need to reduce the “granularity” of your data

 

Let’s say that you check every 10 seconds if there is a MA crossing, then you could:

1)    use 10 sec bars as core data for your backtest

2)    simulate your long and short period MA (based on 5 minute bars) using a multi-periodicity signals

 

but this approach has clearly some main inconvenient :

a) you need to have the complete tick data database on your full backtest period in order to build the 10 seconds bars

b) managing backtesting rules including multiple timeframe reference (and even instruments) instrument is not an easy task

 

However, you are very lucky because IRT is the only software which allows you to do that using the great MPD (Multiperiodicity / instrument) token. If I get some free time, I will write a chapter about using MPD in backtest…


CHAPTER 2 : How to add Money management rules to an IRT  trading system

 

We will discuss in this second chapter the way to write:

=> An initial fixed stop loss and trailing Stop loss

=> Profit taking rules at given targets (including partial exits)

 

In a first step, for simplicity, all stop and targets “increments” will be in E-minis points.

With the same rules logics, I am sure you will find out how to use, instead of points, percentage levels or eventually fixed dollar amounts.

I will give here the general framework for the typical backtest runs. Then, it will be your task to adapt the trading systems with your signals and filters.

What is great is that you ultimately just need to change a custom indicators and few inputs to be able to backtest a full new trading strategies, or test new kind of Trailing stop (ATR related or whatsoever)

 

In this chapter, we are going to use some key RTL tokens:

 

POS_STATE returns 1 if there is an ongoing Long trade / 2 for a short trade / 0 if no ongoing trade

POS_SIZE returns the current size of your position: +1 your are long one contract / +2: long two contracts / -1 short one contracts / etc / 0: no ongoing trade

BARSOPEN returns the number of bars since entering the trade so the test BARSOPEN = 1 will detect the first bar following the entry signal trigger bar.

Above token are used in backtesting rules only. We are going as well to use extensively the SMIN and SMAX tokens:

For reminder, if (V#1 <= V#2), then

SMIN(V#1,V#2)  returns V#1   and    SMAX(V#1,V#2)  returns V#2

 

 

2.1) Using an EOB approach for money management rules: a logical choice

 

As I do enter systematically my stop and targets in my broker platform as LIMIT order, the End of Bar is THE logical approach for these rules in a backtest. Indeed, I will hit my stop loss or target as soon as a given trade occurs at the corresponding level

 

Let’s consider a long position:

 

For a profit taking rules (ie exit the trade as soon as the PL is higher than X points), the rules will be written according to following logic:

If  HI > TARGET then SELL 2 at TARGET price

This is the same EOB reasoning than before, in order to simulate that my profit taking LIMIT Order is filled; I will test for the High of the current bar to be STRICTLY higher than my target one

 

Similarly; for an initial STOP LOSS rules,

If  LO < STOP  then SELL 2 at STOP price

 

In fact, even if IRT has the variable STOP included in RTL, we are going to use systematically V variables in order to:

 

1) input the Stop and Target increment in Points

2) store the resulting different Stop and Target prices that will appear in the “Rule Price” popup menu of the Trading system definition window.

 

The exact syntax will be detailed later on

 

In my current trading systems, I use about 200 V# variables for different purposes. Most of them are in fact there NOT for the control of money management parameters, but for the creation of a fully customized report using the NOTE token. Anyhow, I am going to use the same V variables than the one I currently use, but of course, there is no need  for you to take the same one . Just start from V#1 onwards… 


 

2.2) Definition of the Money Management (MM) variables

 

 

A) The MM INPUT variables  :

 

V#61:       Initial Stop Increment (pt)

V#62:       Trailing Stop Increment (pt)

V#64:       Partial Target Increment (pt)

V#65:       2nd Lot Target Increment (pt)

 

These data may be introduced thru a __L_S_Initialize_Variables trading signal (to be associated to a NONE action):

SET(V#61,3) and SET(V#62,5) and SET(V#64,7) and  SET(V#65,10) 

 

In this case, there is a 3 point Initial Stop loss, a 5 pt trailing stop, a partial target set at 7 point (i.e. one from the two lot will be sold/bought at this price) and a profit taking target set at 10 pt for the remaining 2nd lot

Of course, if you don’t want have any profit target in your backtest, just set V#64 and 65 to 1000 pt for example.

 

In a first stage, we will keep this value constant during the backtest, and use the same value for both short and long positions.

 

 

 

B)    Definition of the Stop and targets Price Variables

 

We are going to use as well the following V variables for storing stop and target price:

V#51:       Initial Stop Price

V#52:       Trailing Stop Price

V#54:       Partial Target Price

V#55:       2nd Lot Target Price

 

And, as there is no need to keep TWO stop rules, we will be combining them using

 

V#53:       Global Stop Price

 

I am going to store as well inside V#50 the Entry Price (I could use of course the “ENTRY” token instead, but using a V variables is useful for reporting purpose…)

 

Let’s consider a Long trade, getting the initial Stop price and the target prices for the partial and 2nd lot is quite obvious:

 

SET(V#51,V#50-V#61) and SET(V#54,V#50+V#64) and SET(V#55,V#50+V#65)

 

A trailing stop has many possible definition, we will consider here the usual one. If there is an ongoing trade, and IRT is testing the 5th bar, then the trailing stop price for this bar is equal to:

the highest experienced between SINCE the Entry time AND until the previous bar so far a long trade : so we will be using the SET statement

 

SET(V#52,V#58-V#62)

 

Having defined the  HH since Entry variable V#58 thru the statement 

 

SET(V#58,SMAX(HI,V#58))

 

Please note that for the first bar of the trade, we will consider that the HH since Entry is … the Entry Price…

Ok, this seems may be a bit complex, but you only need to define the corresponding rules once and then, they will be valid for any kind of backtest runs…


 

2.3) The money management rules explained step by step

 

Ok, we have all the elements to detail now how to write this money management rules for a LONG position. These seven rules will be inserted between the Long BUY and SELL Rules

 

 

RULE 1:   If__L_S_Detect_Entry_Bar       then CONFIRM     using next rule

SIGNAL=     __L_S_Detect_Entry_Bar:      BARSOPEN =1 and POS_STATE != 0

RULE 2:   If __L_S_Store_Entry_Data      then NO ACTION

SIGNAL=     __L_S_Store_Entry_Data:      SET(V#50,ENTRY) and SET(V#57,CL.1) and

SET(V#58,CL.1)

RULE 3:   If__LNG_Detect_Trade_Ongoing   then CONFIRM      using next rule

SIGNAL=     __LNG_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 1

RULE 4 :  If __LNG_Store_Stops_Tgts      then NO ACTION

SIGNAL=     __LNG_Store_Stops_Tgts:      SET(V#51,V#50-V#61) and SET(V#52,V#58-V#62)  

and SET(V#53,SMAX(V#51,V#52)) and SET(V#54,V#50+V#64) and SET(V#55,V#50+V#65) and SET(V#58,SMAX(HI,V#58))

RULE 5 :  If __LNG_Exit_STP              then SELLSTOP   at Value V#53 price

SIGNAL=     __LNG_Exit_STP:              BARSOPEN >= 1 and LO < V#53

RULE 6:   If __LNG_Exit_PTL              then SELL 1      at Value V#54 price

SIGNAL=     __LNG_Exit_PTL:              BARSOPEN >= 1 and POS_SIZE=2 and HI > V#54

RULE 7:   If __LNG_Exit_TGT              then SELL 2      at Value V#55 price

SIGNAL=  __LNG_Exit_TGT:                 BARSOPEN >= 1 and HI > V#55

Before going any further in a rule position, I need to refresh your memory about an important issue on position size and Action rules:

 

A SELL “2 ES” rules will decrease the size of any long position by a maximum of 2 contracts, but it will never initiate a short position.

Ie, if there were already a partial exit, and that the remaining size is 1 contract long, a SELL 2 will only close this 1 contract position at that’s it.

 

At the opposite, if you have a REVERSE-SELL & SELLSHORT 2, the action will close the Long position, whatever it size (even if it is 5 contracts), and initiate a SHORT position with a SIZE of 2 contracts

 

Ok, let’s see what we've got here:

 

Rule 1 will only detect when the bar tested in the first one in a long or short trade

Rule 2 will then store the Entry Price and initialise the Highest High (resp. Lowest low: V#57) which will be used for the Trailing Stop calculation

These rules are common to both short and long trades

 

Rule 3 will detect if there is an ongoing long trades and then

Rule 4 will update for every bar of the trade life the stop and target values

Please note that the formula SET(V#58,SMAX(HI,V#58)) will store the Highest High until the current Bar : HOWEVER, as this statement is situated after  SET(V#52,V#58-V#62), the V#58 value which will be used for the V#52 computation  is the one which was determined :

š      on the prior iteration (if BARSOPEN > 1)

š      or with Rule number 2 (for BARSOPEN =1) :

this way we are indeed using the Highest high until PREVIOUS bar for the Trailing stop calculation…

 

Moreover for rule 4, we define the global Stop price as the one being the most constraining between the initial stop and the trailing stop thru the statement (for a long trade) : SET(V#53,SMAX(V#51,V#52))

 

 

Rules 5, 6 and 7:

All rules have in common BARSOPEN >= 1. This statement is included to avoid that you exit the trade on the same bar than you entered (which is quite non sense, especially when you enter with an EOB entry signals).

Please note that there is no need to add here a “and POS_STATE=1” statement for these 3 rules: indeed, a SELL or SELLSTOP (which are basically doing the same action, only the name changes) is only tested when a LONG trade is ongoing…

Finally, we added a “POS_SIZE=2” check in the partial exit rules. Indeed, we want only to take a partial ONCE, for the first bar with HI > V#54 being true. When this will be the case, POS_SIZE will become equal to 1, and these rules won’t be able to be true anymore (so no need to use a CONFIRM rule...)

Please note the respective order for rules number 5, 6 or 7:

Indeed, for a given bar, we are going to successively test conditions involving the LO and the HI of the bar. From an historical point of view, there is no way to know if the LO occurred before the HI or reverse.

Indeed, we could imagine that we could have on the same bar (a very outside one for example) both stops and targets hit on the same bar. Here again, I take the conservative approach, i.e. I will consider by default that the STOP is hit first, so I will put the STOP rules on the first place in the list of possible exit signals.

 

Here are the corresponding rules for managing the stop and targets for SHORT trades

 

RULE 4:  If __SHT_Store_Stops_Tgts then NO ACTION

SIGNAL=     __SHT_Store_Stops_Tgts:      SET(V#51,V#50+V#61) and

SET(V#52,V#57+V#62) and SET(V#53,SMIN(V#51,V#52)) and

SET(V#54,V#50-V#64) and

SET(V#55,V#50-V#65) and SET(V#57,SMIN(LO,V#57))

RULE 5 :  If __SHT_Exit_STP              then BUY STOP   at Value V#53 price

SIGNAL=     __SHT_Exit_STP:              BARSOPEN >= 1 and HI >  V#53

RULE 6:   If __SHT_Exit_PTL              then COVERSHORT 1 at Value V#54 price

SIGNAL=     __SHT_Exit_PTL:              BARSOPEN >= 1 and POS_SIZE=-2 and LO < V#54

RULE 7:   If __SHT_Exit_TGT              then COVER 2     at Value V#55 price

SIGNAL=  __SHT_Exit_TGT:                 BARSOPEN >= 1 and LO <  V#55

 

 

You will find at the end of these chapter how these rules are added to an existing trading system with :

š      Filter rules (REF_SYSTEM_A_EOB_MM)

š      Filter and reverse rules (REF_SYSTEM_A_EOB_MM_REV)

I did not attached the scripts for the INB approach because I am sure you can figure out how they works based on the above one..

 

 

 

2.4) How to simplify the “maintenance” works around backtest or how to use exactly the same single trading system for testing different strategies

 

Please, DO NOT be afraid by the number of rules you will end up with your backtest!

Here are good reasons by this apparent complexity:

 

A) First, this is normal there are a lot of rules because we are managing up to 14 different type of entry / exit rules!!

 

If we consider an EOB system with Filter, Reverse and Money management rules, you have to remember that we have, on top of at least one ENTRY rule, 6 types of Exit rules, ie : 4 possible exit rules which are MM related (initial stop / trailing stop / partial and target) and at least 2 exit rules (i.e. the usual Exit signal and the one reversing your position) : so basically you manage 1 + 6 = 7 x 2 = 14 type of entry / exit rules in this trading system (which will have about 20 – 25 rules, including the Filter and V variable ones)

 

 

B) My latest reference trading system includes about 60 rules, but, most of the time, I even don’t change the content of a single trading signal when I want to test another strategy! Let me explain how I achieve that:

 

First, with the trading system rules list as detailed in 2.5, (Let’s consider the REF_SYSTEM_A_EOB_MM for example), you will notice that, in order to test a new trading strategy, you won’t have to add or remove rules from the list, you will just need to modify the content of some trading signals in order to take into account new entry, filter or exit signals. The structure of the trading system remains UNCHANGED.

 

But we can even go one step further, keeping the same modular approach. In this system, the long entry signal (LNG_ENTRY_SIG_EOB) is written as: “CL > STATHI.1”

As you might have guessed, the idea is to keep always the same TRADING signal syntax thanks to the use of a generic custom indicator, i.e. LNG_ENTRY_SIG_EOB will be systematically written as CI_ENTRY_SIGNAL > 0 (and SHT_ENTRY_SIG_EOB as CI_ENTRY_SIGNAL < 0)

 

Indeed, it is always possible to write a custom indicator:

š      returning +1 if a LONG exit signal is triggered

š      returning –1 if a SHORT exit signal is triggered

In the case of the entry Breakout signals of the system REF_SYSTEM_A_EOB_MM,

we will be able to write :

 

CI_ENTRY_SIGNAL = (CL > STATHI.1)*(1) + (CL < STATLO.1)*(-1)

 

the 2 STAT statements (STATHI and STATLO) being equal as usual to the 10 bar period maximum HI and Minimum LO

 

For the exit rules, the same logic can be used, i.e. I will have always:

LNG_EXIT_SIG_EOB as CI_EXIT_SIGNAL < 0

SHT_EXIT_SIG_EOB as CI_EXIT_SIGNAL > 0

 

By the way, CI_ENTRY_SIGNAL does have exactly the same syntax than the ENTRY one, i.e.

CI_EXIT_SIGNAL = (CL > STAT_HI.1)*(1) + (CL < STAT_LO.1)*(-1)

except that both STAT statement are here based on the 7 bar period

 

The same generic approach will be used in all my Filter rules, for example:

 

__LNG_FILTER_EOB  will be always (CI_TIME_FILTER > 0) * (CI_TREND_FILTER>0) > 0

 

With        CI_TIME_FILTER = (TIME>1540)*(TIME<2150)

and         CI_TREND_FILTER = (ADX>25)*(ADX>ADX.1)

 

(if we want to be in line with REF_SYSTEM_A_EOB_MM)

 

Conclusion: I will never change the way I write my trading signals rules (for a given global approach of course, like the EOB one). This means that the only variable input (in terms of signals) of my trading systems is a list of 4 custom indicators:

CI_ENTRY_SIGNAL

CI_EXIT_SIGNAL

CI_TIME_FILTER

CI_TREND_FILTER

 

Testing another trading strategies can be summarized in updating a list of 4 or 5 custom indicators.. You will quickly forget that the trading system is based on 2 dozens of rules as you will most of the time never look in them but just update your trading system input CI.

 

Final remark:

In order to update your stop target level increment, you may update before running the backtest the value included in the __L_S_Initialize_Variables rule. In if you’re a very lazy and don’t want to open a trading signal window, you may even remove this SET statement from the trading system AND introduce directly the corresponding V values thru a dedicated Quote Page… A solution to be reserved for the “advanced” user however…

 

 


 

2.5) Detailed scripts of the trading systems discussed in Chapter 2

 

Nothing new here: you just need to combine the MM management rules set (i.e. 7 for Long + 7 for short) with the basic trading systems of Chapter 1

 

I will not give all possible combination so you will find here but just :

 

EOB entry/exit rules WITH (Filter + MM) rules  and WITHOUT reverse rules

INB entry/exit rules WITH (Filter + MM) rules  and WITHOUT reverse rules

EOB entry/exit rules WITH (Filter + MM + REV) rules

 

Here we go:

 

2.5.1) End Of Bar Basic system with FILTER and MM rules

 


 

Detailed Report: REF_SYSTEM_A_EOB_MM

 

RULE 1: 1 Minute: If __L_S_Initialize_Variables then NO ACTION

SIGNAL=__L_S_Initialize_Variables: SET(V#61,3) and SET(V#62,5) and SET(V#64,7) and  SET(V#65,10) 

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

 

RULE 2: 1 Minute: If __LNG_FILTER_EOB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 3: 1 Minute: If __LNG_ENTRY_SIG_EOB then BUY 2 at Last price

SIGNAL=__LNG_ENTRY_SIG_EOB: CL > STAT.1

ELEM=CL:Close

ELEM=STAT:Statistics:STAT[Scan] MAX H10

 

RULE 4: 1 Minute: If __SHT_FILTER_EOB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB: (TIME>1540)*(TIME<2150)* )*(ADX>25)*(ADX>ADX.1)  > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 5: 1 Minute: If __SHT_ENTRY_SIG_EOB then SELL SHORT 2 at Close price

SIGNAL=__SHT_ENTRY_SIG_EOB: CL < STATLO.1

ELEM=CL:Close

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

 

RULE 6: 1 Minute: If __L_S_Detect_Entry_Bar then CONFIRM using next rule

SIGNAL=__L_S_Detect_Entry_Bar: BARSOPEN =1 and POS_STATE != 0

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 7: 1 Minute: If __L_S_Store_Entry_Data then NO ACTION

SIGNAL=__L_S_Store_Entry_Data: SET(V#50,ENTRY) and SET(V#57,CL.1) and SET(V#58,CL.1)

ELEM=V#50:Entry Price

ELEM=V#57:LL since Entry

ELEM=V#58:HH since Entry

ELEM=ENTRY:Entry price

ELEM=CL:Close

 

RULE 8: 1 Minute: If __LNG_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__LNG_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 1

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 9: 1 Minute: If __LNG_Store_Stops_Tgts then NO ACTION

SIGNAL=__LNG_Store_Stops_Tgts: SET(V#51,V#50-V#61) and SET(V#52,V#58-V#62)  and SET(V#53,SMAX(V#51,V#52)) and SET(V#54,V#50+V#64) and SET(V#55,V#50+V#65) and SET(V#58,SMAX(HI,V#58))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#58:HH since Entry

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=HI:High

 

RULE 10: 1 Minute: If __LNG_Exit_STP then SELL STOP at Value V#53 price to exit

SIGNAL=__LNG_Exit_STP: BARSOPEN>=1 and LO < V#53

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

 

RULE 11: 1 Minute: If __LNG_Exit_PTL then SELL 1 at Value V#54 price

SIGNAL=__LNG_Exit_PTL: POS_SIZE =  2 and BARSOPEN >=1 and HI > V#54

ELEM=POS_SIZE:Size of position

ELEM=V#54:Partial Target Price

ELEM=HI:High

ELEM=BARSOPEN:No. bars in position

 

RULE 12: 1 Minute: If __LNG_Exit_TGT then SELL 2 at Value V#55 price

SIGNAL=__LNG_Exit_TGT: BARSOPEN >= 1 and HI > V#55

ELEM=V#55:2nd Lot Target Price

ELEM=BARSOPEN:No. bars in position

ELEM=HI:High

 

RULE 13: 1 Minute: If __LNG_Exit_SIG_EOB then SELL 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L7

ELEM=CL:Close

 

RULE 14: 1 Minute: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 15: 1 Minute: If __SHT_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__SHT_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 2

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 16: 1 Minute: If __SHT_Store_Stops_Tgts then NO ACTION

SIGNAL=__SHT_Store_Stops_Tgts: SET(V#51,V#50+V#61) and SET(V#52,V#57+V#62) and  SET(V#53,SMIN(V#51,V#52)) and SET(V#54,V#50-V#64) and SET(V#55,V#50-V#65) and SET(V#57,SMIN(LO,V#57))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=V#57:LL since Entry

ELEM=LO:Low

 

RULE 17: 1 Minute: If __SHT_Exit_STP then BUY STOP to cover at Value V#53 price

SIGNAL=__SHT_Exit_STP: BARSOPEN >= 1 and HI > V#53

ELEM=HI:High

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

 

RULE 18: 1 Minute: If __SHT_Exit_PTL then COVER SHORT 1 at Value V#54 price

SIGNAL=__SHT_Exit_PTL: POS_SIZE = - 2 and BARSOPEN >=1 and LO < V#54

ELEM=POS_SIZE:Size of position

ELEM=LO:Low

ELEM=V#54:Partial Target Price

ELEM=BARSOPEN:No. bars in position

 

RULE 19: 1 Minute: If __SHT_Exit_TGT then COVER SHORT 2 at Value V#55 price

SIGNAL=__SHT_Exit_TGT: BARSOPEN >= 1 and LO < V#55

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

ELEM=V#55:2nd Lot Target Price

 

RULE 20: 1 Minute: If __SHT_Exit_SIG_EOB then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H7

 

RULE 21: 1 Minute: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=EXIT_SIGNAL:Custom Indicator:CI:_CI__Exit_Signal_BT[Scan]

ELEM=TIME:Backtest Time (hhmm)

 

 


2.5.2) Intra-Bar Basic system with FILTER and MM rules

 

 


RULE 1: 5 Minutes: If __L_S_Store_Bkout_value then NO ACTION

SIGNAL=__L_S_Store_Bkout_value: SET(V#2,STATHI.1) and SET(V#3,STATLO.1) and SET(V#4,STAT_HI.1) and SET(V#5,STAT_LO.1)

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=STAT_HI:Statistics:STAT[Scan] MAX H7

ELEM=STAT_LO:Statistics:STAT[Scan] MIN L7

ELEM=V#2:Highest High prev 10 bars

ELEM=V#3:Lowest Low prev 10 bars

ELEM=V#4:Highest High prev 7 bars

ELEM=V#5:Lowest Low prev 7 bars

 

RULE 2: 5 Minutes: If __L_S_Initialize_Variables then NO ACTION

SIGNAL=__L_S_Initialize_Variables: SET(V#61,3) and SET(V#62,5) and SET(V#64,7) and  SET(V#65,10) 

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

 

RULE 3: 5 Minutes: If __LNG_FILTER_INB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_INB: (TIME>1540)*(TIME<2150)*(ADX.1>25)*(ADX.1>ADX.2) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 4: 5 Minutes: If __LNG_ENTRY_SIG_INB then BUY 2 at Last price

SIGNAL=__LNG_ENTRY_SIG_INB: HI>V#2

ELEM=HI:High

ELEM=V#2:Highest High prev 10 bars

 

RULE 5: 5 Minutes: If __SHT_FILTER_INB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_INB: (TIME>1540)*(TIME<2150)* *(ADX.1>25)*(ADX.1>ADX.2)  > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

ELEM=LRS:Linear Regression Slope:LRS [Scan] 1,S,9

 

RULE 6: 5 Minutes: If __SHT_ENTRY_SIG_INB then SELL SHORT 2 at Close price

SIGNAL=__SHT_ENTRY_SIG_INB: LO<V#3

ELEM=LO:Low

ELEM=V#3:Lowest Low prev 10 bars

 

RULE 7: 5 Minutes: If __L_S_Detect_Entry_Bar then CONFIRM using next rule

SIGNAL=__L_S_Detect_Entry_Bar: BARSOPEN =1 and POS_STATE != 0

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 8: 5 Minutes: If __L_S_Store_Entry_Data then NO ACTION

SIGNAL=__L_S_Store_Entry_Data: SET(V#50,ENTRY) and SET(V#57,CL.1) and SET(V#58,CL.1)

ELEM=V#50:Entry Price

ELEM=V#57:LL since Entry

ELEM=V#58:HH since Entry

ELEM=ENTRY:Entry price

ELEM=CL:Close

 

RULE 9: 5 Minutes: If __LNG_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__LNG_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 1

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 10: 5 Minutes: If __LNG_Store_Stops_Tgts then NO ACTION

SIGNAL=__LNG_Store_Stops_Tgts: SET(V#51,V#50-V#61) and SET(V#52,V#58-V#62)   and SET(V#53,SMAX(V#51,V#52)) and SET(V#54,V#50+V#64) and SET(V#55,V#50+V#65) and SET(V#58,SMAX(HI,V#58))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#58:HH since Entry

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=HI:High

 

RULE 11: 5 Minutes: If __LNG_Exit_STP then SELL STOP at Value V#53 price to exit

SIGNAL=__LNG_Exit_STP: BARSOPEN>=1 and LO < V#53

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

ELEM=V#39:Offset correcting rnding errors

 

RULE 12: 5 Minutes: If __LNG_Exit_PTL then SELL 1 at Value V#54 price

SIGNAL=__LNG_Exit_PTL: POS_SIZE =  2 and BARSOPEN >=1 and HI > V#54

ELEM=POS_SIZE:Size of position

ELEM=V#54:Partial Target Price

ELEM=HI:High

ELEM=BARSOPEN:No. bars in position

 

RULE 13: 5 Minutes: If __LNG_Exit_TGT then SELL 2 at Value V#55 price

SIGNAL=__LNG_Exit_TGT: BARSOPEN >= 1 and HI > V#55

ELEM=V#55:2nd Lot Target Price

ELEM=BARSOPEN:No. bars in position

ELEM=HI:High

 

RULE 14: 5 Minutes: If __LNG_Exit_SIG_INB then SELL 2 at Close price

SIGNAL=__LNG_Exit_SIG_INB: LO < V#5

ELEM=LO:Low

ELEM=V#5:Lowest Low prev 7 bars

 

RULE 15: 5 Minutes: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 16: 5 Minutes: If __SHT_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__SHT_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 2

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 17: 5 Minutes: If __SHT_Store_Stops_Tgts then NO ACTION

SIGNAL=__SHT_Store_Stops_Tgts: SET(V#51,V#50+V#61) and SET(V#52,V#57+V#62)  and  SET(V#53,SMIN(V#51,V#52)) and SET(V#54,V#50-V#64) and SET(V#55,V#50-V#65) and SET(V#57,SMIN(LO,V#57))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=V#57:LL since Entry

ELEM=LO:Low

 

RULE 18: 5 Minutes: If __SHT_Exit_STP then BUY STOP to cover at Value V#53 price

SIGNAL=__SHT_Exit_STP: BARSOPEN >= 1 and HI > V#53

ELEM=HI:High

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

 

RULE 19: 5 Minutes: If __SHT_Exit_PTL then COVER SHORT 1 at Value V#54 price

SIGNAL=__SHT_Exit_PTL: POS_SIZE = - 2 and BARSOPEN >=1 and LO < V#54

ELEM=POS_SIZE:Size of position

ELEM=LO:Low

ELEM=V#54:Partial Target Price

ELEM=BARSOPEN:No. bars in position

 

RULE 20: 5 Minutes: If __SHT_Exit_TGT then COVER SHORT 2 at Value V#55 price

SIGNAL=__SHT_Exit_TGT: BARSOPEN >= 1 and LO < V#55

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

ELEM=V#55:2nd Lot Target Price

 

RULE 21: 5 Minutes: If __SHT_Exit_SIG_INB then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_SIG_INB: HI > V#4

ELEM=HI:High

ELEM=V#4:Highest High prev 7 bars

 

RULE 22: 5 Minutes: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=EXIT_SIGNAL:Custom Indicator:CI:_CI__Exit_Signal_BT[Scan]

ELEM=TIME:Backtest Time (hhmm)


2.5.3) End Of Bar system with FILTER, MM & REV rules

 

 

Detailed Report: REF_SYSTEM_A_EOB_MM_REV

 

RULE 1: 5 Minutes: If __L_S_Initialize_Variables then NO ACTION

SIGNAL=__L_S_Initialize_Variables: SET(V#61,3) and SET(V#62,5) and SET(V#64,7) and  SET(V#65,10) 

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

 

RULE 2: 5 Minutes: If __LNG_FILTER_EOB then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 3: 5 Minutes: If __LNG_ENTRY_SIG_EOB then BUY 2 at Last price

SIGNAL=__LNG_ENTRY_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 4: 5 Minutes: If __SHT_FILTER_EOB then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

 

RULE 5: 5 Minutes: If __SHT_ENTRY_SIG_EOB then SELL SHORT 2 at Close price

SIGNAL=__SHT_ENTRY_SIG_EOB: CL < STATLO.1

ELEM=CL:Close

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

 

RULE 6: 5 Minutes: If __L_S_Detect_Entry_Bar then CONFIRM using next rule

SIGNAL=__L_S_Detect_Entry_Bar: BARSOPEN =1 and POS_STATE != 0

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 7: 5 Minutes: If __L_S_Store_Entry_Data then NO ACTION

SIGNAL=__L_S_Store_Entry_Data: SET(V#50,ENTRY) and SET(V#57,CL.1) and SET(V#58,CL.1)

ELEM=V#50:Entry Price

ELEM=V#57:LL since Entry

ELEM=V#58:HH since Entry

ELEM=ENTRY:Entry price

ELEM=CL:Close

 

RULE 8: 5 Minutes: If __LNG_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__LNG_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 1

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 9: 5 Minutes: If __LNG_Store_Stops_Tgts then NO ACTION

SIGNAL=__LNG_Store_Stops_Tgts: SET(V#51,V#50-V#61) and SET(V#52,V#58-V#62)   and SET(V#53,SMIN(SMAX(V#51,V#52),HI)) and SET(V#54,V#50+V#64) and SET(V#55,V#50+V#65) and SET(V#58,SMAX(HI,V#58))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#58:HH since Entry

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=HI:High

 

RULE 10: 5 Minutes: If __LNG_Exit_STP then SELL STOP at Value V#53 price to exit

SIGNAL=__LNG_Exit_STP: BARSOPEN>=1 and LO < V#53

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

 

RULE 11: 5 Minutes: If __LNG_Exit_PTL then SELL 1 at Value V#54 price

SIGNAL=__LNG_Exit_PTL: POS_SIZE =  2 and BARSOPEN >=1 and HI > V#54

ELEM=POS_SIZE:Size of position

ELEM=V#54:Partial Target Price

ELEM=HI:High

ELEM=BARSOPEN:No. bars in position

 

RULE 12: 5 Minutes: If __LNG_Exit_TGT then SELL 2 at Value V#55 price

SIGNAL=__LNG_Exit_TGT: BARSOPEN >= 1 and HI > V#55

ELEM=V#55:2nd Lot Target Price

ELEM=BARSOPEN:No. bars in position

ELEM=HI:High

 

RULE 13: 5 Minutes: If __SHT_FILTER_EOB_REV then CONFIRM using next rule

SIGNAL=__SHT_FILTER_EOB_REV: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1)*(POS_STATE=1) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 14: 5 Minutes: If __LNG_Exit_SIG_EOB then REVERSE-SELL & SELL SHORT 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=CL:Close

 

RULE 15: 5 Minutes: If __LNG_Exit_SIG_EOB then SELL 2 at Close price

SIGNAL=__LNG_Exit_SIG_EOB: CL < STATLO.1

ELEM=STATLO:Statistics:STAT[Scan] MIN L10

ELEM=CL:Close

 

RULE 16: 5 Minutes: If __LNG_Exit_MKT_CL then SELL 2 at Close price

SIGNAL=__LNG_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

 

RULE 17: 5 Minutes: If __SHT_Detect_Trade_Ongoing then CONFIRM using next rule

SIGNAL=__SHT_Detect_Trade_Ongoing: BARSOPEN >= 1 and POS_STATE = 2

ELEM=BARSOPEN:No. bars in position

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 18: 5 Minutes: If __SHT_Store_Stops_Tgts then NO ACTION

SIGNAL=__SHT_Store_Stops_Tgts: SET(V#51,V#50+V#61) and SET(V#52,V#57+V#62)  and  SET(V#53,SMAX(LO,SMIN(V#51,V#52))) and SET(V#54,V#50-V#64) and SET(V#55,V#50-V#65) and SET(V#57,SMIN(LO,V#57))

ELEM=V#50:Entry Price

ELEM=V#51:Initial Stop Price

ELEM=V#52:Trailing Stop Price

ELEM=V#53:Global Stop Price

ELEM=V#54:Partial Target Price

ELEM=V#55:2nd Lot Target Price

ELEM=V#61:Initial Stop Increment (pt)

ELEM=V#62:Trailing Stop Increment (pt)

ELEM=V#64:Partial Target Increment (pt)

ELEM=V#65:2nd Lot Target Increment (pt)

ELEM=V#57:LL since Entry

ELEM=LO:Low

 

RULE 19: 5 Minutes: If __SHT_Exit_STP then BUY STOP to cover at Value V#53 price

SIGNAL=__SHT_Exit_STP: BARSOPEN >= 1 and HI > V#53

ELEM=HI:High

ELEM=V#53:Global Stop Price

ELEM=BARSOPEN:No. bars in position

 

RULE 20: 5 Minutes: If __SHT_Exit_PTL then COVER SHORT 1 at Value V#54 price

SIGNAL=__SHT_Exit_PTL: POS_SIZE = - 2 and BARSOPEN >=1 and LO < V#54

ELEM=POS_SIZE:Size of position

ELEM=LO:Low

ELEM=V#54:Partial Target Price

ELEM=BARSOPEN:No. bars in position

 

RULE 21: 5 Minutes: If __SHT_Exit_TGT then COVER SHORT 2 at Value V#55 price

SIGNAL=__SHT_Exit_TGT: BARSOPEN >= 1 and LO < V#55

ELEM=BARSOPEN:No. bars in position

ELEM=LO:Low

ELEM=V#55:2nd Lot Target Price

 

RULE 22: 5 Minutes: If __LNG_FILTER_EOB_REV then CONFIRM using next rule

SIGNAL=__LNG_FILTER_EOB_REV: (TIME>1540)*(TIME<2150)*(ADX>25)*(ADX>ADX.1)*(POS_STATE=2) > 0

ELEM=TIME:Backtest Time (hhmm)

ELEM=ADX:Average Directional Ind:ADX [Scan] (14) (14)

ELEM=POS_STATE:Backtest state 1=long 2=short

 

RULE 23: 5 Minutes: If __SHT_Exit_SIG_EOB then REVERSE-COVER & BUY 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 24: 5 Minutes: If __SHT_Exit_SIG_EOB then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_SIG_EOB: CL > STATHI.1

ELEM=CL:Close

ELEM=STATHI:Statistics:STAT[Scan] MAX H10

 

RULE 25: 5 Minutes: If __SHT_Exit_MKT_CL then COVER SHORT 2 at Close price

SIGNAL=__SHT_Exit_MKT_CL: (TIME = 2200)

ELEM=TIME:Backtest Time (hhmm)

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

J Temporary end of the tutorial J

I hope you enjoyed it and learned few stuff

 

Thank you for reporting any tipping mistake or inconsistencies you may have found at f_trader02@yahoo.fr