A few backtesting/autotrading questions  [SOLVED]

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

A few backtesting/autotrading questions

Postby bowlesj3 » 05 Sep 2017

Update so save some reading if you are just starting.
I did the tests mentioned in the 5th post below. The result of the test is that the indicators (and even a dummy signal) placed in the 5 minute bars chart) did not execute when I ran a backtest. This was true when I ran the backtest from the 1 minute bar chart and in the portfolio backtester which has the 5 minute bars listed as a data set for the symbol. So as per the topic the question is "how do I get the GVs from other studies/indicators in other chart resolutions into the 1 minute bar chart signal script that executes the orders?" As mentioned in the thread it would be better if these other resolution scripts/studies could be included as part of the backtest rather than have to copy large amounts of duplicate code into a single script.
Hi, I have a very basic back testing question. Well sort of :D . One question compounded into about three. Before I can ask the questions I first have to explain my general approach to trading that I have developed over about 13 years. I describe it in the next paragraph then do my best to ask the questions.

Basics of my system:
My system involves visually reading multiple levels of waves in the market. I read them in a multi level manor meaning as the upward 1/2 of a parent wave is moving up it consists of a series of child waves and these child waves have smaller grandchild waves. That is the basic idea (waves within waves within waves). Although my trading system also takes into account resistance points and support points (bounces as I often call them) the biggest component of any trade I take will be where 2 or 3 levels of waves are shifting toward greater profit in the direction I am considering (long/short). In the past I could not figure out how to get MultiCharts to read these waves properly. Only within the last month or so have I started to figure out how to develop MultiCharts scripts that can read the waves in the market very close to the way I read them (matching at about 80% to 90%). So with this breakthrough in hand I am focusing my attention on back testing and auto trading. So in order to try and work toward having MultiCharts back test my strategy I have worked out chart resolutions that will be set such that they are likely to capture the various wave levels. For example the lowest wave level is picked up by the 1 minute bars, the next bigger wave level is picked up by the 5 minute bars, the next bigger wave level is picked up by the 15 minute bars, etc.

The questions:
The signal that executes the entry/exit orders will be in the 1 minute bars. However it will not signal entry into the market until it determines (1/ a good trigger exists and 2/ Global Variables are set indicating that the upper level waves say it is okay to take the trade). Here is all I know how to do at this point. To back test I go to (format my 1 minute bar signal, click optimize, click Exhaustive, click okay, change at least one input so it will allow me to click okay, click okay) and I get my performance report. Seems easy (It runs through the 1 minute bars twice applying each of the two settings for my input). However that creates a question. Does it also process the other resolutions (5 minute, 15 minute, 30 minute, daily, weekly) such that it will have the GV input it needs? If not will the portfolio trader help (I noticed it has a back testing, optimization and automatic order execution). I am also asking myself if I have to start using "Data2, Data3 in my 1 minute bars chart for the higher resolution info that is required for my system. Last question. I was gathering ideas on using the scanner to scan up to 100 stocks with the 64 bit version of MultiCharts then auto-trade up to 5 stocks for a day then I noticed the portfolio trader and I am wondering if the portfolio trader is better suited for this goal?

Hopefully this is clearer than mud :D . Any thoughts on how to go about this would be appreciated.

Thanks,
John
Last edited by bowlesj3 on 05 Sep 2017, edited 7 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: A few backtesting/autotrading questions

Postby TJ » 05 Sep 2017

Is it possible to put all the "Waves" in one chart?
That would eliminate the need for GV.
With the 64bit MC, you can expand the size of your data in one chart, making multi-data analysis (and backtest) a lot easier.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: A few backtesting/autotrading questions

Postby bowlesj3 » 05 Sep 2017

Is it possible to put all the "Waves" in one chart?
That would eliminate the need for GV.
With the 64bit MC, you can expand the size of your data in one chart, making multi-data analysis (and backtest) a lot easier.
I am aware I can run 64 bit MC on a computer with 64 gig of ram and it may just solve the running out of memory popup I am getting.

I am not sure if I can get several resolutions on one chart. I was reading about merging data into one chart but it sounds like you can only merge real time data in with historical data. Even if I can get more than one resolution on one chart it is not ideal since I may have some time to watch a trade in progress and it will be a lot easier if all resolutions are on separate charts. So in other words maybe the portfolio trader or the scanner is running the scripts to auto trade but I open workspaces for each symbol with an open position so I can check in every so often and maybe spot trouble before the script does.

Just so happens this video which I was in the process of watching before I started this thread (at location 51:00) shows putting more than one data series on a chart (but in subcharts).
https://www.youtube.com/watch?v=FE1KAI1snVI


Right now I am watching Youtube videos on these topics (far superior than reading since as they say a picture is with 1,000 words and a video is worth a billion) :-) I have not had time to dig into the portfolio trader much but I did see a button on a video that allows one to close out a trade manually before the script does it.

Even if there is more than one way to go about this and even if one knows all the ways, knowing the best way is a whole other question.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: A few backtesting/autotrading questions

Postby evdl » 05 Sep 2017

Maybe you can use "synthetic" bars. But the symbol of the different resolutions must be the same for that. You can program your own resolutions build from the 1 minute resolution. In that way you can have all resolutions in one signal, without the quirks of how MC is dealing with multi data streams, GV's, intrabar, barmagnifier etc. And backtesting and optimizing will also be easier and faster.

Apart from that you can always setup separate charts for live watching, but backtesting and trading is all done from one chart with a signal which calculates multiple resolutions.

One drawback of this is that you may have to adjust functions and indicators to get the right values, but that depends on what you need.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: A few backtesting/autotrading questions

Postby bowlesj3 » 05 Sep 2017

I was just playing around with the Portfolio trader which has tabs for (backtesting, Optimization, Forward testing, and Auto order execution). I was able to enter basically what I have to do (see attached picture with the notes). It appears at first glance that it should be processing all the different resolutions in sync with each other such that the 1 minute chart should have the correct (go or no-go indicator) from each of the other resolutions on that same row. The only signal resolution that would actually have an entry/exit order would be the 1 minute bars signal (the others would send a Global Variable with a 1=okay and 0=Not-Okay). I guess the next thing to do is try it with one symbol and run the same thing on a chart and see if they match up in terms of the backtesting reporting of the number of trades, profit, etc. A lot of fileappend writes would be needed to make sure it is indeed doing what it is suppose to be doing.

I need to read about the Automatic order execution tab before I dare click on it :-) I certainly don't want these two (monkey around with it) signals running live.
Attachments
Portfolio_Trader_Learning.png
(111.25 KiB) Downloaded 840 times
Last edited by bowlesj3 on 06 Sep 2017, edited 2 times in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: A few backtesting/autotrading questions  [SOLVED]

Postby bowlesj3 » 05 Sep 2017

I did the tests mentioned in the post immediately above (5th post). The result of the test is that the indicators (and even a dummy signal) placed in the 5 minute bars chart did not execute when I ran a backtest. This was true when I ran the backtest from the 1 minute bar chart and in the portfolio backtester which has the 5 minute bars listed as a data set for the symbol. So as per the topic the question is "how do I get the GVs from other studies/indicators in other chart resolutions into the 1 minute bar chart signal script that executes the orders?" As mentioned in the thread it would be better if these other resolution scripts/studies could be included as part of the backtest rather than have to copy large amounts of duplicate code into a single script.

Workarounds if needed:
I will be surprised if MC can't handle my trading system because I don't think this is anything new (waves within waves within waves should be obvious to everyone). However, if it can't be done by the portfolio tracker maybe I can do this. I currently have my database program step the scanner to ensure all data is coming to the charts for all the 75 or so symbols. GVs tell my database program when all studies have been completed and my database program waits until that time. This runs the chart studies historically front to back for all symbols. For backtesting (because the studies process bar by bar until last bar on a chart one at a time) there has to be a first pass on all this where the shift information from each chart is written out to a file for later processing by the signal. The file must have the date/time when the wave shift has occurred and another record with date and time for when the wave shift has ended. During the 2nd pass these file records are brought into the 1 minute bar chart signal study for matching record processing so the signal can know when the swings in the other charts give it the yes or no. Pass 2 could be backtested using the portfolio trader for sure but unless the portfolio trader can process pass 1 as well doing everything in sync it could not optimized since most of the optimizing would involve changes to the interpretation of the wave shifts. For live auto-trading there is no need to do this double pass matching routine and the GVs will work. I don't think MC's playback feature could be used or backtesting since as far as I know it can not work with the scanner and it also can not work with the backtesting feature. Backtesting with this 2 pass method would be slow but very doable. The scanner could be used for live autotrading since I know for sure it processes all resolutions and the GVs can be sent out (I need to check the order of execution across each row of the scanner). If autotrading can not run from the scanner then at the very worst the Database program could detect a signal coming via the scanner's running all resolutions and the database program will open the special workspace ahead of time where the autotrade takes place. The database program would be smart enough to close the workspace once the trade is finished. The database program would be smart enough to limit the number of open workspaces to five. These are all kind of cumbersome but again doable if MC can't handle this. Better cumbersome that nothing. If the backtesting results are good enough it would save me a boatload of work :-) What I describe is much like my semi-automated system I am finalizing now. It notifies me of a trade. I decide if I like the way the system has interpreted the (wave shift, breaks and support-resistance). If I like it I then set the method of triggering and it tells me when to use the chart trader to get in. The idea is you need to be pretty sharp for the triggering and it helps me out. I might automate the triggering. It then notifies me when it thinks I should get out (the whole thing is reversed). If it gets it wrong at least the stop is there.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: A few backtesting/autotrading questions

Postby bowlesj3 » 07 Sep 2017

I have decided to mark this as solved since the two pass approach to backtesting mentioned in the above post is fine.


Return to “MultiCharts”