Click here to Login

                                                   Timeframe Script


2022-05-24 02:27:37

This is the script for changing the timeframe of the active chart (this one changes timeframe to weekly)

Chart c = Charts.GetSelectedChart();
c.TimeFrame = 7;
c.IsHistorical = true;

I am looking for some help/hint to get something like the following:

If the existing Timeframe =1, then TimeFrame() =7
If the existing Timeframe =7, then TimeFrame() =31
If the existing Timeframe = 31 then TimeFrame()=90
Else TimeFrame() =1

Idea is to get one keyboard shortcut to toggle between 4 different timeframes.

Also could anyone manage to code which can shift from linear scale to log scale. I am told by QS that its not possible (may be there is no function available for scaling).

2022-05-26 12:19:11


Best Answer
You can do something like:

c.TimeFrame = 7;
else if(c.TimeFrame==7)
c.TimeFrame = 31;
else if(c.TimeFrame==31)
c.TimeFrame = 90;
c.TimeFrame = 1;

2022-05-27 01:22:11


Thats brilliant. Any workaround to create a keyboard shortcut to shift from linear to log and back?

2022-05-30 17:22:36


It is not possible to change that dynamically unfortunately.

2022-05-31 00:23:31


Pls see if it can be added as a feature in the next version

No more messages


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"


Trading Items
Identify Spilts Screener Script
Multi TimeFrame RSI
System Metrics v2.0
Currency Mgmt v 0.9
Relative Performance/Return Chart - Compare Several Assets/Stocks...

How-to Lessons
How to run a screen or a watchlist from a script
How to get stocks for a particular index using the global script
How to execute a script at regular intervals
How to get trading orders from a portfolio programmatically
How to add a metric in the trading system simulation report

Related Forum Threads
Script Trading Example
code for roc of certain script
Money Management script and exit options in the wizard
AMM ATS script
Reinvest Dividends in Your Trading System - Script

Blog Posts
QS Trading Software: Global Script
Charting & Scripts - Manage stock charts using the global script
How scripts communicate with each other
How to Reference Drawing Studies in QS Formulas
Update Chart Layout based on Active Ticker Symbol - Part 2

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
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.