Click here to Login

                                                   help with logic


Amritendu Maji
2017-07-31 12:05:36

Thank you for your continual support and help. It is very much appreciated.

I am trying to write this code in QS but can't figure it out. Please provide a code snippet to help.

We are using daily data.
a = Lastweek's high
b = This week's low
c = EMA(close, 50); // ---- Daily EMA at the end of this week
d = EMA(close+5, 50); // ---- Daily EMA at the end of last week

e = iff(a < d && b > c, 1, 0);

What is the formula/code to assign to a and b.

Thank you.

Amritendu Maji
2017-08-01 01:06:49


Now let us assume we are using weekly data.

a = High[1];
b = Low;

c = EMA(close, 50); // ---- Daily EMA at the end of this week
d = EMA(close+5, 50); // ---- Daily EMA at the end of last week

e = iff(a < d && b > c, 1, 0);

How do we make c and d use daily data?

Thank you.

2017-08-01 08:15:09


Functions such as "timeframeapply" allows you to access other time frame data. However, you will be able to access weekly bar data for example only when it is completed and thus "this week low" cannot be accessed.

You need to write something like this:
a = timeframedecompress(timeframeapply(7, high));
a = ref(a, 1);
nw = week() != ref(week(), 1);
b = lowestsince(nw, low);

Accessing daily data in weekly time frame is not possible unless a custom c# code is written in "Tools -> Create Functions".

Amritendu Maji
2017-08-01 11:12:31


Thank you for the reply.

Can you recommend an example to see how to access daily data in weekly time frame?

I am trying to learn QS, so your help is very much appreciated.

Thank you,

2017-08-02 09:59:00


In "Tools -> Create Functions", you need to use the "cFunctions.GetTimeframeData" function to access data for a specific time frame.

Amritendu Maji
2017-08-02 13:40:20


Thank you for the reply. Where can I get a list and description of these items like cFunctions.GetTimeframeData, TA.Value(closes,firstbar) etc.?

Just like the QS language guide, that I am still reading and learning, a guide for these functions will help people like us.

Thank you.

2017-08-03 05:47:45


Best Answer
In the script editor, use CONTROL+SPACE to display the list of available functions at any moment. Click on the "Help" red button at the bottom of the script editor.

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
Long Term Up Trend with Short term re-entery Signals
Update the Stock Exchange Associated With U.S. Stocks - Market Fi...
Stock Correlation with its Industry - Change over time
Top 20 stocks with the highest 10 day rate of change - Current an...
Minimum Variance Optimization with Solver V1.1- AMM

How-to Lessons
How to use QuantShare with Metastock data
How to associate an index with a list of stocks
How to screen for stocks having a high correlation with the Dow J...
How to create a chart with a black background
How to speed up watchlist and screener plug-ins when working with...

Related Forum Threads
Help With Daily Data Import Script
Need help with a MM Script
Help with Quantshare Language
Help with Survivorship Bias Free DB
Help with a Red/Green positive/negative hatched graph?

Blog Posts
Working with the formula editor
How to deal with StockTwits data
How to Backtest an Intraday Stock Trading System with EOD Ranking
How to Optimize a Trading System with Thousands of Billions of Co...
Create Profitable Trading Strategies with Exchange Traded Funds (...

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

Copyright 2021
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.