NexusFi: Find Your Edge


Home Menu

 





Backtest TOS Excel Alpha Beta Sharpe


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,983 views
    2. thumb_up 2 thanks given
    3. group 1 followers
    1. forum 14 posts
    2. attach_file 8 attachments




 
Search this Thread

Backtest TOS Excel Alpha Beta Sharpe

  #1 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90

Hi all,
I hope this isnt too hard a problem... or that there is a fast solution

I have a strategy or a few, and i have run the back test on them in TOS
before i go somewhere else to re-write things (python), and expose my tech
I would like to do some analysis and try to see the value of what i have (or dont have)

Its pretty easy to do the back test of years in TOS platform. Its far from ideal, and there are a lot of drawbacks (like no trailing stop losses, etc). but for a start to get an idea if more effort should be put into something, its good enough at this point. I already know there are other places that have more, but some of them cost lucre i dont have now, some of them are crowdsourcing for their own funds, and some are in between hoping to make trade by machine (and what cash i have for trading is locked up in things right now)..

and its easy to bring your test into Excel (easier if you dont save as CSV and save as HTML and cut and paste)

what i want to do is put that test data into Excel, then do some analysis
and was wondering if there was some pre-made spreadsheets that can do this with the TOS data already
i really really dont want to re-invent the wheel... cart... and loading bays..

normally i wouldn't bother, but my latest strategy is performing exceptionally well
and it would help a great deal to progress that beyond just curiosity in TOS and make choices as to whether or not to use it myself in some platform, license it, etc... regardless, better data and analysis is needed before i expend a huge amount of work on moving forward to other potentials.

I included a sample output in excel...

Its a three year daily back-test...
Opening Trade was $30,000.00
Total P/L: $1,745,000.00

Symbol: /ZC:XCBT
Work Time: 2/8/17 - 1/23/20
Total P/L: $1,745,000.00
Total order(s): 54


PS there is also a BearTest that also goes with it
Opening Trade was $10,000.00
Total P/L: $1,636,250.00

Symbol: /ZC:XCBT
Work Time: 2/6/17 - 1/23/20
Max trade P/L: $338,750.00
Total P/L: $1,636,250.00
Total order(s): 54

Attached Files
Elite Membership required to download: BullTest01.xlsx
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106

4.14 r/r | 74.00% win | $32,314.81 expectancy/trade | 54 trades
$420,000.00 largest win | $47,656.25 avg win | -$28,750.00 largest loss | $11,517.86 average loss

If you're using anything other than close[0] as your entry in your code your results are going to be way off.

If you are using close[0] then terrific results, although 54 trades in 3 years is a strategy that only trades 7% of the time.
I'm not sure that's enough data.

Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90


the code computes its entry/exit point on close..

but could you make your point clearer? i do wish to make sure this is correct!!

is not using close a quirk? or a limitation of back test?
does the add buy in TD not check to see if the buy was possible? (does it add blindly)
or (as i thought) the add buy happens on the next candle?

its critical that this ends up right, which i am sure you know given money is ultimately involved.

thanks for answering, its really appreciated...

Reply With Quote
  #4 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Artfldgr View Post
the code computes its entry/exit point on close..

but could you make your point clearer? i do wish to make sure this is correct!!

is not using close a quirk? or a limitation of back test?
does the add buy in TD not check to see if the buy was possible? (does it add blindly)
or (as i thought) the add buy happens on the next candle?

its critical that this ends up right, which i am sure you know given money is ultimately involved.

thanks for answering, its really appreciated...

YOu'll have to look at the time of day the strat entered...I'm not going to do that ha

Did you not see the r/r, win%, expectancy I posted above?

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90

Im reading through the expectancy now... thx..
i am also checking, double and triple checking and rerunning...

not the most fun part, but definitely more fun than the expectancy of
winning and watching it go swirly despite it saying, hey your winning..

the number of trades is actually double as the point was to reverse
but the td software didnt like the idea of selling to close and selling to open on the same moment
or i had it wrong... which is always a possibility and must be ascertained constantly...

thanks!!!

[ps cool avatar]

Reply With Quote
  #6 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Artfldgr View Post
Im reading through the expectancy now... thx..
i am also checking, double and triple checking and rerunning...

not the most fun part, but definitely more fun than the expectancy of
winning and watching it go swirly despite it saying, hey your winning..

the number of trades is actually double as the point was to reverse
but the td software didnt like the idea of selling to close and selling to open on the same moment
or i had it wrong... which is always a possibility and must be ascertained constantly...

thanks!!!

[ps cool avatar]

use buy_auto and sell_auto to close/reverse position

Thanks man. Buffalo Bill! A legend.

Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90

and do you too dance by the light of the moon when you come out? (ref to old song)

Reply With Quote
  #8 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


Artfldgr View Post
and do you too dance by the light of the moon when you come out? (ref to old song)


Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90

I was now looking where to use my code...
while its not perfect on thinkorswim... it does very well..
you can see it does... I was watching it do its signal..
monday will be a human test... close enough..
pick a stock, set active trader to 100 shares, then buy and sell when the code tells you
but only long... not short...

i tried it today, but my emotions got in the way...
meaning... trust it and dont think... duh..

on the other side, i was adapting my code for quantopian..
but i just found out that you lose your rights to your IP (effectively)
so now i am looking at quantiacs - which doesnt do that..

Also it appear quantopian changed their payment model from a share, to a share in a pool...
its one thing to get a share of what your code produces...
its another thing to get a share of a fixed pool.. in which they make more and more and the programmers get less and less...

why is it that people cant resist killing the golden goose? (greed is not enough of an answer as not killing it would satisfy greed much more than killing it!!!!!!!!!!!!)

i just deleted my test code.. ie. i am removing it from quantopian and will work on some lesser stuff there
and given their model, they cant use my stuff without my signing it... and my test was not good (cause i didnt get to do the test code correctly yet... )

there is also taking 5k, and getting robinhood, and using their rest api..

on my journal posts i am using the code to do some manual swing trading at the day level
that doesnt require speedy response, and does quite well

i was thinking and it doesnt matter if its only trading 7% (long only) to 14%(with shorts)..
what matters is how much it makes... though its funny... it would have been nice for the days where you paid commissions... but now that you dont.. ... too funny.. but you can easily make up its low rate on one stock by playing many stock..

mondays test will be cool..
100 shares only... as many of the tests do several hundred dollars using only that, and trading the day
IF that works, then i can always up it... (though the problem is stop limits... no way to set it up to always have them... yes, there is oco, and yes you can add it after your trade... but both are slow... it is what it is.. )

opinions... advice... etc

you do know cody has two graves, yes?

Reply With Quote
Thanked by:
  #10 (permalink)
Artfldgr
New York + New York / USA
 
Posts: 76 since Jan 2020
Thanks Given: 2
Thanks Received: 90


hey...
forgot to add that i will be paper trading the algorithm on monday by hand..
i watched it today and played around (totally screwing up my paper record.. oh well)
and its hard to believe it... ie. you just dont trust it but then, it works...
if it works this good in practice.. ie. you buy when it says buy, sell when it says sell
it will be like printing money... (which is unbelievable and i am still trying to find the hole)

I can tell that the TD backtest is off... but NOT so much that it would kill its performance in general





and here is a clear example where you can see its off..
but if you look as well, it doesnt negate the results it just makes them not perfect.



I will bet that a better backtest with more accurate numbers, would not change the overall result much
in this case, 100 shares, traded 63 times in the day.. in and out... yielded 770..
maybe with tighter modeling, it might be 500 taking 270 off for arguments sake

the larger point is that it's goodness (for lack of a better term), comes from how it captures the larger longer moves
it would definitely work in a better trading situation where it could use the close of the current minute
and then get a price close to that current candle sans the few exceptions.. here its infrequency is a benefit!

ALSO... it tends to miss the actual top and lose quite a bit there..
in this case, what the model misses in its tiny differences, can be made up by improving exit code
AND selecting stock with better odds of uptrends over mining the pull backs in down trends also

i have to see now about what Quantiacs can do in terms of better (more accurate) back testing...
though i may still do stuff on Quantopian, but i wont submit it to their contest or for cash given their huge contract

Do you know a platform that has a rest API that allows trading... robin hood?
or one in which you can add your code and let it trade forwards?

I am really sure this will earn... given that the results above are with just 100 shares..
add a zero for 1000 shares and divide in half for the small inaccuracy... (which would be smaller than half)

applying that to this selection from this mornings scans would yield $7,701.60 / 2 = $3,850.80

thoughts?

heck, at the very least it may point to nice day chart swing trades.. also a thing in which the entry price can be off from the model and still win big... looking over stuff this morning while searching, about 1/5th of the large gaps up were covered by a buy a few candles back...

Reply With Quote




Last Updated on January 26, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts