Click here to Login





                                                   Script to run scanner and increment date?

  0

0
Jared Seaton
2021-10-29 19:26:50


I saw the following How-To, and I was wondering if it's possible to have the script increase/decrease the date of the scan and rerun until a certain date/number of days incremented? I want to scan historical dates at a specific hour, and it's pretty tedious to run it, wait, then adjust the date, and repeat.

https://www.quantshare.com/how-423-how-to-run-a-screen-or-a-watchlist-from-a-script




QuantShare
2021-11-08 09:47:08

  1

Best Answer
Hi,

You can run a screen at a specific date/time using this function:
Screener.Run("", "name", "mm/dd/yyyy hh:mm:ss");

The script will look like this: (Just an example)

DateTime date = new DateTime(2021, 8, 20);
for(int i=0;i<20;i++)
{
string ddate = date.ToString("MM/dd/yyyy hh:mm:ss");
Screener.Run("", "name", ddate);
date = date.AddDays(1);
}




Jared Seaton
2021-11-12 20:51:11

  0

Awesome, that was very helpful. What I've put together seems to work, but it's not outputing symbols. One thing I found, is that in the Output it's showing the time as 03/19/2020 04:30:00 when I am using "DateTime date = new DateTime(2020, 3, 19, 16, 30, 00);" . Should this show as 03/19/2020 16:30:00?

When I run the scan manually for 3/19/2020 16:30 I get one result.

DateTime date = new DateTime(2020, 3, 19, 16, 30, 00);

for(int i=0;i<3;i++)
{
string ddate = date.ToString("MM/dd/yyyy hh:mm:ss");
ScreenTask task = Screener.Run("", "15MHV", ddate);
date = date.AddDays(-1);
while(!task.IsCompleted)
{
App.Main.Sleep(500);
}
Global.Trace(date.ToString("MM/dd/yyyy hh:mm:ss"));
for(int j=0; j< task.ScreenResults.Length;j++)
{
string symbol = task.ScreenResults[j].Symbol;
Global.Trace(symbol);
}

}



QuantShare
2021-11-14 12:56:04

  0

For the output, try using
MM/dd/yyyy HH:mm:ss
instead of
MM/dd/yyyy hh:mm:ss

to display the time in 24 hour format instead of 12 hour format



Jared Seaton
2021-11-15 19:12:28

  0

That helped the timestamp display, thank you. However now it seems that it's not actually running the screener with the incrementing dates. I have the screener saved with 3/19/20 as the date, which does have one result. When I run the script, it prints out the same symbol from 3/19/20 for each date. Do I need to do the screener.run differently, or maybe move things around?

DateTime date = new DateTime(2020, 3, 19, 16, 30, 00);
for(int i=0;i<3;i++)
{
string ddate = date.ToString("MM/dd/yyyy HH:mm:ss");
ScreenTask task = Screener.Run("", "15MHV", ddate);
while(!task.IsCompleted)
{
App.Main.Sleep(500);
}
Global.Trace(date.ToString("MM/dd/yyyy HH:mm:ss"));
for(int j=0; j< task.ScreenResults.Length;j++)
{
string symbol = task.ScreenResults[j].Symbol;
Global.Trace(symbol);
}
date = date.AddDays(-1);
}



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Identify Spilts Screener Script
Head and Shoulders Pattern
Optimizable Fibonacci Long and Short Trading System
Entry Price and Exit Price in Trading System Report
Historical EOD data for LSE-listed Stocks and ETFs

How-to Lessons
How to run a screen or a watchlist from a script
How to execute a script at regular intervals
How to get stocks for a particular index using the global script
How to download EOD quotes for active and valid stocks only
How to plot support and resistance lines automatically

Related Forum Threads
Money Management Script variables and more
Money Management script and exit options in the wizard
Adding symbols and changing properties from script
Accessing Symbol Info in Screener, Strategy script and in MM tool...
Can I update the sector and industry information in the stock dat...

Blog Posts
How to build and backtest a robust stock trading system
QS Trading Software: Global Script
Backtest Trading Strategies Programmatically and on Schedule
Step by step on how to get free realtime/delayed data for stocks,...
How to get buy and sell orders for a portfolio based on a trading...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright 2022 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.