STARTING FROM SCRATCH IN BACKTESTING
STARTING FROM SCRATCH IN BACKTESTING
hi all,
i been trading discretionary, but recently got some ideas i'd love to test using TRADING BLOX BUILDER 2.0.6
i am totally confused on how am i writting a script and making the blox. i tried doing it but the results didnt come up... can anyone help me do that?
i just wanna catch the basics of the programming the system using software.
for instance:
i want to buy (enter) a commodity(stock) on monday and sell (exit) on wednesday. no stops.
how am i programming this simple example into a trading blox builder, what am i to do with blocks:parameters, indicators?
thanks in advance
i been trading discretionary, but recently got some ideas i'd love to test using TRADING BLOX BUILDER 2.0.6
i am totally confused on how am i writting a script and making the blox. i tried doing it but the results didnt come up... can anyone help me do that?
i just wanna catch the basics of the programming the system using software.
for instance:
i want to buy (enter) a commodity(stock) on monday and sell (exit) on wednesday. no stops.
how am i programming this simple example into a trading blox builder, what am i to do with blocks:parameters, indicators?
thanks in advance
-
- Roundtable Knight
- Posts: 154
- Joined: Fri Apr 22, 2005 9:14 pm
- Location: Vancouver, Canada
I just started experimenting with it so I am nowhere near qualified to respond, but I'll give it a shot anyway.
For such an incredibly simple system I dont believe you need ANY parameters or indicators.
Parameters would be required if you wanted to test different permutations of days - eg. Mon/Wed, Tue/Thur and so on. If you are content to fix (hardcode) it as M/W, you dont need parameters.
Similarly indicators are for calculated data such as a moving average. If you are just going off days of week, you dont need to manipulate the price data a all.
Now, I can't see how you can easily, or even with difficulty code a rule based on day of week. There is a day of month function that you could apply to tesst.currentdate but I don't see one for day of week.
Perhaps someone from TTS will answer this?
For such an incredibly simple system I dont believe you need ANY parameters or indicators.
Parameters would be required if you wanted to test different permutations of days - eg. Mon/Wed, Tue/Thur and so on. If you are content to fix (hardcode) it as M/W, you dont need parameters.
Similarly indicators are for calculated data such as a moving average. If you are just going off days of week, you dont need to manipulate the price data a all.
Now, I can't see how you can easily, or even with difficulty code a rule based on day of week. There is a day of month function that you could apply to tesst.currentdate but I don't see one for day of week.
Perhaps someone from TTS will answer this?
-
- Site Admin
- Posts: 9015
- Joined: Tue Apr 06, 2004 1:41 pm
- Location: Boston, MA
- Contact:
-
- Site Admin
- Posts: 9015
- Joined: Tue Apr 06, 2004 1:41 pm
- Location: Boston, MA
- Contact:
Sure thing:
1) Create a new block called "DayOfWeek Entry Exit". Make in an "Entry and Exit" type block.
2) Select the Entry Orders script area and put the following code in:
3) Select the Exit Orders script area and put the following code in:
4) Create a new System called "DayOfWeek System" and drag this block in. You can also drag in the Basic Money Manager at this time, so you can select the size of the position.
5) Select the system and run a test.
Hope that helps. I've attached the block in case that is helpful. You can right click on the attachment, and save in your "Blox" folder. you can then review the block, and add to the system as in step 4.
1) Create a new block called "DayOfWeek Entry Exit". Make in an "Entry and Exit" type block.
2) Select the Entry Orders script area and put the following code in:
Code: Select all
VARIABLES: dayOfWeek TYPE: integer
' Get the day of the week as a number
dayOfWeek = toJulian( test.currentdate ) mod 7
' Go Long on Monday
IF dayOfWeek = 1 THEN
broker.EnterLongOnOpen
ENDIF
3) Select the Exit Orders script area and put the following code in:
Code: Select all
VARIABLES: dayOfWeek TYPE: integer
' Get the day of the week as a number
dayOfWeek = toJulian( test.currentdate ) mod 7
' Exit position on Wednesday
IF dayOfWeek = 3 THEN
broker.ExitAllUnitsOnOpen
ENDIF
5) Select the system and run a test.
Hope that helps. I've attached the block in case that is helpful. You can right click on the attachment, and save in your "Blox" folder. you can then review the block, and add to the system as in step 4.
- Attachments
-
- DayOfWeek Entry Exit.tbx
- (1.89 KiB) Downloaded 841 times
-
- Site Admin
- Posts: 9015
- Joined: Tue Apr 06, 2004 1:41 pm
- Location: Boston, MA
- Contact:
Hi,
The simple way is to replace the broker.ExitAllUnitsOnOpen with broker.EnterShortOnOpen. An Entry order will automatically exit the existing position if there is one.
This will cause multiple units to be put on in the case of holidays, so I wrote a smarter version that I have attached. It checks to see if you are long or short, so it only puts on one unit.
Best,
Tim
The simple way is to replace the broker.ExitAllUnitsOnOpen with broker.EnterShortOnOpen. An Entry order will automatically exit the existing position if there is one.
This will cause multiple units to be put on in the case of holidays, so I wrote a smarter version that I have attached. It checks to see if you are long or short, so it only puts on one unit.
Best,
Tim
- Attachments
-
- DayOfWeek Entry Exit.tbx
- (1.96 KiB) Downloaded 722 times
Tim, thanks a lot for your assitance , it helps me a lot! i just came out with a system that has Maximum Total Equity Drawdown % =0.00% !
i am look at the chart of the trades and its exactly what i was thinking of and what i pragrammed. auto debugger helped me do that. i am still analyzing the Summary Results that TBB be just gave me and i'll place the entire results list in a little while.
i am look at the chart of the trades and its exactly what i was thinking of and what i pragrammed. auto debugger helped me do that. i am still analyzing the Summary Results that TBB be just gave me and i'll place the entire results list in a little while.
-
- Site Admin
- Posts: 9015
- Joined: Tue Apr 06, 2004 1:41 pm
- Location: Boston, MA
- Contact:
Best bet is to review the Outer Loop document. It's in the manual, and I've attached it here as well.
The way TBB processes a trading day is to set the test date equal to today, set the instrument date equal to yesterday, and generate orders. Then it sets the instrument date equal to today to see if any of the orders got filled.
So in the entry script, instrument.close is yesterday's close. And when you say broker.enterLongOnOpen, it is for today. So on any given trading day the only data you have access to is yesterday's data. Not until all orders are placed will TBB move ahead to today.
So notice that in the After Instrument Day script you test date is equal to instrument date and you have access to all of today's properties.
It's just a way of looking at things. It's easier if you get into the TBB mindset rather than always thinking of placing orders for tomorrow. You are placing them for today (the test today) but using yesterday's data.
Hope that helps!
The way TBB processes a trading day is to set the test date equal to today, set the instrument date equal to yesterday, and generate orders. Then it sets the instrument date equal to today to see if any of the orders got filled.
So in the entry script, instrument.close is yesterday's close. And when you say broker.enterLongOnOpen, it is for today. So on any given trading day the only data you have access to is yesterday's data. Not until all orders are placed will TBB move ahead to today.
So notice that in the After Instrument Day script you test date is equal to instrument date and you have access to all of today's properties.
It's just a way of looking at things. It's easier if you get into the TBB mindset rather than always thinking of placing orders for tomorrow. You are placing them for today (the test today) but using yesterday's data.
Hope that helps!
- Attachments
-
- outerloop.doc
- (32 KiB) Downloaded 900 times
Tim, thanks a lot for explaining that... so now i understand that if i am doing the test i have to think in terms:" its morning (EST), i sit and test the markets before they open today and generate orders that will be placed after the markets will open".Tim wrote:So in the entry script, instrument.close is yesterday's close. And when you say broker.enterLongOnOpen, it is for today. So on any given trading day the only data you have access to is yesterday's data. Not until all orders are placed will TBB move ahead to today.
i got confused about how to write script for the day's close "before yesterday", meaning if instrument.close is the yesterday's close how am i writting in a script language of TBB a close that was before instrument.close
hello traders,
so i've been working on the code of my mechanical system and i backtested it and got some interesting results. i dont know how to attach a file right from the TBB so i just printed out the summary test results and scanned them. Tim , do you think it's a realisitc results? 0.1% drawdown and 100% winning months. 32.72 MAR? i called it TT system (working name)
so i've been working on the code of my mechanical system and i backtested it and got some interesting results. i dont know how to attach a file right from the TBB so i just printed out the summary test results and scanned them. Tim , do you think it's a realisitc results? 0.1% drawdown and 100% winning months. 32.72 MAR? i called it TT system (working name)
- Attachments
-
- 0 drawdown system.rar
- TT system
- (310.97 KiB) Downloaded 879 times
-
- Site Admin
- Posts: 9015
- Joined: Tue Apr 06, 2004 1:41 pm
- Location: Boston, MA
- Contact: