Simple Scanner script keeps restarting?  [SOLVED]

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

Simple Scanner script keeps restarting?

Postby bowlesj3 » 29 Jul 2019

UPDATE: I think I might have this problem resolved. In order to get real time updates into my script and to not have it restarting all the time I have to put my simple script in the scanner (in the lower watch window instead of the scanner window). See the last post.

Hi,
I am having serious issues with the scanner. I am hoping I am doing something wrong but I think not and this may become a bug report. I am using MC64 Ver11 build 15808.

It started out with what looked like the scanner bogging down due to too many rows so I wrote an MS-Access script to send key strokes to the scanner such that for every new trading day it will built the scanner with only the rows required for a short list of stocks. Works great. Today it built a scanner with 13 symbols and each symbol has 6 resolutions/charts (1 Week, 1 Day, 30M. 15M, 5M, 1M). So today's scanner has 6 X 13 = 78 rows. This is way less than required for the 65 stocks I manually chart scan every night for stocks that might set up the next day. So I started today thinking this short list scanner might solve the problems. Sadly Not.

The script I am using started out being really simple. Specifically on every bar calculate the RSI and on the LastBarOnChart send out the current RSI to a GV which my MS-Access program reads in and processes. The scanner data range for all rows is 520 which matches the six charts. Long ago I discovered they needed to match up for the RSI to be accurate.

So over the the past week the script has become cluttered with debugging statements so that I can be notified immediately of a problem by a MS-Access popup in its timer routine. MS-Access grabs the GV values every second. I just put in a simple single GV field so that MS-Access could report a problem and the scripts FileAppend Statements could provide the details. So great. I figured maybe I can adjust the time and date comparison statements and get it to work. Unfortunately the currentBar = 1 statement keeps getting executed over and over and the FileDelete statement keeps deleting my FileAppend information on me. IN other words the script is executing a hidden recalculate for some reason. I have scanned it searching for "[" and "(" hoping to find something I missed that might be exceeding the max bars back setting of 22 I have chosen. No such command exists from what I can see. I just removed the FileDelete and put a FileAppend in at CurrentBar=1 to show the MaxBarsBack. It is consistently set to 22. So it appears it is not doing the hidden recalculate to reset the maxBarsBack to something it is happy with (MC likes the 22 setting). A while back I learned that 22 is required even though the RSI only needs 14.

One thing I have noticed might be related. In the scanner display sometimes some of the "Trend" column icons show "waiting for data.." even though it was once filled out. I am thinking it is at this time that it is restarting the script.

I tried commenting out the RecalcLastBarAfter(1); command but that did not seem to change anything.

So I can't think of anything that might be causing the hidden recalculate. Is this a known issue? Might anyone know of a solution?


Thanks.
John
Last edited by bowlesj3 on 31 Jul 2019, edited 12 times in total.

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

Re: Simple Scanner script keeps restarting?

Postby bowlesj3 » 29 Jul 2019

I just tried removing "execute on every tick" then took the script out of the scanner and put it back in. No luck.

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

Re: Simple Scanner script keeps restarting?

Postby bowlesj3 » 29 Jul 2019

I did a screen snapshot of the output report for one stock after spacing out the lines so I could mark in comments showing the problems.
ScannerList.png
(94.62 KiB) Downloaded 187 times
I am pretty sure I have the edits correct now.

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

Re: Simple Scanner script keeps restarting?  [SOLVED]

Postby bowlesj3 » 30 Jul 2019

I think I solved it. As I was hoping it was my not fully understanding the scanner that was the problem. In order to get real time updates into my script and to not have it restarting all the time I have to put my simple script in the scanner (in the lower watch window instead of the scanner window). The picture below details exactly what I have to do. At this point I can not get the scanner to display the exact same RSI as the chart but I figure that is a different issue.
ScannerSetupProcedures.png
(129.57 KiB) Downloaded 167 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Simple Scanner script keeps restarting?

Postby Henry MultiСharts » 31 Jul 2019

Hello John,

Pre-Scanning requests both historical and realtime snapshot data after a certain time interval pre-set by a user. It is not constantly receiving the realtime data. The instruments satisfying the conditions are copied into Watchlist automatically. Since you do not need this functionality, you can remove all instruments from Pre-Scanning and add them into Watchlist directly. Watchlist is a standard version of MultiCharts Scanner that is constantly receiving the realtime data.
You can learn more here: https://www.multicharts.com/trading-sof ... _Watchlist

As for the indicator values being different in the scanner and on the chart - you need to configure all of the symbol and indicator settings the same way both in the scanner and on the chart. In most of the cases users have different results due to the data range and max bars back being configured differently.

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

Re: Simple Scanner script keeps restarting?

Postby bowlesj3 » 31 Jul 2019

Since you do not need this functionality, you can remove all instruments from Pre-Scanning and add them into Watchlist directly. Watchlist is a standard version of MultiCharts Scanner that is constantly receiving the realtime data.
Thanks Henry, I didn't realize this. That will save me all the steps I mentioned in the above picture I posted. I can simply highlight the watch list window and MS-Access will built the short list of stocks in the watch-list instead. So cool :-)
As for the indicator values being different in the scanner and on the chart - you need to configure all of the symbol and indicator settings the same way both in the scanner and on the chart. In most of the cases users have different results due to the data range and max bars back being configured differently.
I went over this very carefully and they are the same (#bars=520, maxbarsback=22 and RSI setting of 14). What I noticed yesterday when I put the plot values in the scanner (shown in the picture of my prior post) is that the scanner (much like the chart) has a bit of time lag in seconds before the new bar is placed. This is not surprising since MC has a lot to do and it pretty much has to do things one at a time even though my quad core helps out a fair bit. So this accounts for the difference in RSI value on the chart versus the corresponding cell in the watch list. At the same time I noticed that if I closed the scanner workspace and reopened it this corrected the RSI values that were wrong because of this time lag. So this morning I reprogrammed my script with some code to do a controlled recalculate if the time lag is greater than a certain amount. I initially set it to 30 seconds then update it to 60 seconds (daily bar resolution and weekly bar bar resolution are a different). So this seems to have fixed it. In this code I also put in a method to control the recalculating such that if it had an average of more than 10 recalculates per hour it shut down the recalculates process. Basically I didn't want it to go into an endless recalculate loop. So if for example it exceeded 20 recalculates within the first 2 hours it shut down the process all together. So today the RSI values seem pretty good over all. I am very pleased with it. It does not seem to be lagging as much as yesterday either. I am not sure if this is because of my recalculate loop or not. I included the new code I created in a pla file should anyone want to check it out. There is a fairly big comment at the top. My MS-access program looks at the GV count as well and displays if for me in the stock list I use there so I can keep tabs on it. If the recalculate loop gets shut off it shows up as an error in MS-Access.

Thanks again, I guess I should try to find some time to upgrade MC. Always so busy :-)
John
Attachments
ControlledRecalculate.pla
(50.09 KiB) Downloaded 143 times


Return to “MultiCharts”