Rev. 11.1
1. Introduction
DBATE is using an external excel file for developing and storing Trading Algorithms and strategies. The file is called a worksheet and is loaded every time when DBATE opens as well as every time the User is changing the algorithms to its parameters.
IMPORTANT! The strategies in the SAMPLE WORKSHEET were profitable during a specific time in the past and may NOT continue to be profitable beyond some point. NOTE: the average suggested lifespan of any trading strategy should be between 6 to 52 weeks. Please do not use any strategy beyond 52 weeks.
1. TABS in the worksheet
Each tab in the worksheet represents a strategy for one specific symbol. The user can keep adding as many tabs as he/she wants to trade in parallel.
IMPORTANT! The structure of the worksheet as well as all the headers must remain as-is since they function as commands for DBATE. Please do NOT change any of the command lines.
2. Structure of headers
2.1 The first group of commands is related to the security intended for trading. Commands “Parameter”, “Value” which are coming in the “Security” section are related to the choice of security.
2.2 The second group of commands are related to Those commands are the definitions of the rules and conditions of the traded strategy.
IMPORTANT! The Grey and the Yellow lines must remain as-is with at least one space line space before, to enable DBATE to read the commands which follow after these headers
2.3 The next 4 sections are used for developing and writing Sets of rules for user developed Trading Algorithms and are referred herein and after as Entry and Exit conditions. The four sections are:
- Conditions for entry into a long position: “Buy Long when:”
- Conditions for exit from a long position: “Sell Long when:”
- Conditions for entry into a short position: “Sell Short when:”
- Conditions for exit from a short position: “Buyback Short when:”
NOTE: Please keep space lines between sections
3. SECTION 1 – Security parameters
- Exchange – Users can choose from the list of available exchanges as per user’s brokerage account authorizations. Full list of exchanges is list on IBRK website in the link below:
https://www.interactivebrokers.com/en/index.php?f=1562
examples: SMART, ARCA, TSE, SEHK, NSE, TSEJ
- Symbol – the symbol user wants to trade (for the current Tab)
examples: AMZN, XOM, FB, TSLA, XLB
- Currency – please check with broker the currency of the selected exchange
4. SECTION 2 – Strategy parameters
- Active – this line is to turn ON and OFF the trade on this tab in the worksheet
“TRUE” – is a command to turn it ON
“FALSE” – is a command to turn it OFF
- Bar sizes – are as per the broker options and user purchased refresh rate
Examples are mentioned in description column.
NOTE: write “sec”, “min”, “hour”, “day” when the count is 1, and “secs”, “mins”, “hours”, “days” when the count is more than one.
Examples – 1 min, 10 mins
- BT start & end dates – is used for backtester timeframe and for calculating moving averages
NOTE: please refer to description for details
- Exit EOD – enables / disables intra-day trading
Use “TRUE” – when you want the position to be closed on EOD
Use “FALSE” – when you want the position to be held overnight
NOTE: Exact EOD time is defined in “latest trade exit time” command
- Stop loss percent – this filed is automatically creating and placing Stop loss orders on all traded placed by the strategy (maximum allowed loss)
IMPORTANT! We strongly recommend using Stop Loss function in all algorithms. This can protect in even in cases of internet connections issues or any other unexpected technical issues.
- Delay and entry & exit – this function is used to create delays before and after trades. The used parameter is defining the number of candles that strategy should wait until re-start of trading.
NOTE: please refer to description for more details
- Recheck Live every – is used to define the rate of price check for intra-candle movements for live trader.
NOTE: The parameter is in MINUTES
IMPORTANT! Intra-candle price movements of securities may create differences between the entries and exits of live trading and backtester results. Please use related commands carefully.
- Trade quantity – the size of trading position (No. of shares)
IMPORTANT! PLEASE ENSURE THE ENTERED POSITION SIZE IS AS PER YOUR ACCOUNT SIZE, DIVERSIFICATION GOALS AND RISK MITIGATION STRATEGY
- Earliest trade time – for entering after specified time (in the morning)
NOTES:
- Please check your time zones carefully.
- Please check your computer time zone carefully
- In the sample worksheet provided the time zone is New York Standard time (EST)
- Latest trade entry time – is used for specifying the latest entry time during trading hours)
NOTE: This function is used to protect trading algorithms and strategies against the high volatility which may occur in the first few minutes of trade.
- Latest trade exit time – is used or specifying the time for closing daily positions (intraday trading)
- NOTE: This function is used to protect trading algorithms and strategies against the high volatility which may occur in the last session of the daily trade.
- Share fee/Trade fee – these 3 fields are used in Backtester for more accurately estimating costs of trades based on user agreement with the broker.
5. SECTION 3 – Strategy Rules
5.1 Strategy rules can have up to 4 vertical sections. Each section has an unlimited number of lines used an AND logic between the lines withing the same section, and an unlimited number of horizontal sections separated with OR logic within the same vertical section.
5.2 The 4 vertical sections are:
- Sets of rules for Buy long
- Sets of rules for Sell long
- Sets of rules for Sell short
- Sets of rules for buyback short
5.3 DBATE commands
Grey and yellow lines shown below contain DBATE commands and should be kept structured as in the Sample worksheet.
Syntax rules:
- Do not delete or change these commands.
- Keep all commands in the same line
- Keep one line employ before the command line
- Keep only one column empty between sets
- You can copy commands for adding more sets of rules
- You can add lines
- You can add columns
- Ensure both grey line and yellow line are kept structured with spaces as shown in the sample worksheet provided.
5.4 Sets of Rules in each section
To Create a new section (set of rules) you simply copy the yellow command line after a one column gap and start writing your rules.
Each section can have an unlimited number of lines, all are using AND logic between them.
(Means – this set of rules will be met only when all conditions together are met.)
IMPORTANT! When adding lines to a new set of rules, please ensure that lines in the previous sections are not displaced or gapped and that commands are in the same line separated by one cell
NOTE: Syntax of all rules and commands are explained in the Syntax section.
Syntax
PARAMETER | DESCRIPTION | MEANING OF EXPRESSION | IS | MEANING OF EXPRESSION | IS | ||
Open | Opening price of a candle | OPEN | 3 | Opening price of 3th candle ago | |||
High | High price of a candle | HIGH | 2 | High price of 2nd candle ago | |||
Low | Low price of a candle | LOW | 5 | Low price of 5th candle ago | |||
Close | Closing price of a candle | CLOSE | Closing price of the previous candle | CLOSE | 4 | Closing price of the candle 4th candle ago | |
SMA | Simple Moving Average ( of closing prices ) | SMA | 26 | Value of SMA with period 26 at last close | SMA | 26,5 | Value of SMA (26), measured 5 candles ago |
EMA | Exponential Moving Average ( of closing prices ) | EMA | 10 | Value of EMA with period 10 at last close | EMA | 10,2 | Value of EMA (5), measured 2 candles ago |
Slope | Slope of the SMA line in previous bar compared to N bars back, in fraction units | SLOPE | 10 | Slope of SMA (10) at last close | SLOPE | 50,3 | Slope of SMA (50) measured 3 candles ago |
RegSlope | Regression slope of all Close values in previous N bars | REGSLOPE | 3 | Slope of prev 3 Close prices | REGSLOPE | 5,2 | Slope of prev 5 Close prices measured 2 candles ago |
Change | Change in price (as a fraction) (0.5 means 50%) | CHANGE | 5 | Change in price from the close price of 5th candles back | CHANGE | 10,3 | Change in price over 10 candles measured 3 candles ago |
Volume | Candle volume | VOLUME | 3 | Volume of the candle 3 candles ago | |||
AvgVol | Avg. volume in previous N candles | AVGVOL | 5 | Average Volume of last 5 candles | AVGVOL | 10,2 | Average Volume of 10 candles measured 2 candles ago |
WAP | Candle Weighted Average Price | WAP | 3 | Weighted average price of the last 3 candles | WAP | 3,1 | WAP of the previous 3 candles measured 1 candle ago |
VWAP | Volume-weighted avg. Close prices | VWAP | 5 | VWAP with period 5 | VWAP | 10,2 | VWAP with period 10 measured 2 candles ago |
MACD | MACD (12,26) | MACD | MACD (12,16) as a standard, no parameter needed | ||||
RSI | RSI with defined length | RSI | 14 | RSI with period 14 | RSI | 14,1 | RSI with period 14 one candle ago |
Body | Close vs. Open prices (as fraction) | BODY | 3 | Body of the candle 3 candles ago | |||
Height | High vs. Low prices (as fraction of Close) – Absolute value [always positive] | HEIGHT | 3 | Height of the candle 3 candles ago | |||
TR | True range of candles | TR | 5 | TR of the candle 5 candles ago | |||
ATR | Avg. (SMA) true range of bars | ATR | 3 | TR of the candle 5 candles ago | ATR | 5,2 | ATR of 5 candles , 2 candles ago |
Highest | The highest value in last x bars | HIGHEST | 20 | Highest price during last 20 candles (This can be used as a support level ) | |||
Lowest | The lowest value in last x bars | LOWEST | 50 | Lowest price during last 20 candles (Can be used as a resistance level ) | |||
lowOrLast | in Backtester: same as “low”; in Live trader: same as “last price” |
used without values | |||||
highOrLast | in Backtester: same as “high”; in Live trader: same as “last price” |
used without values | |||||
LastPrice | in BackTester: candle Close price; in Live trader: same as “last” |
used without values | |||||
LastVolume | Bar volume as reported by IB; Used to calculate the relative volume of the curent bar (proportionately) | used without values | |||||
BarsSinceEntry | Number of Bars since last Exit | used without values | |||||
BarsSinceExit | Number of Bars since last Exit | used without values | |||||
SetOfLastEntry | Set Number used for Last Entry | used without values | |||||
SetOfLastExit | Set Number used for Last Exit | used without values |