Click here to Login





                                                   SUM for the past X days with intraday time series

  0

0
umair
2013-03-10 21:40:30


a = Crossindicator(close);
b = hour() == 16;
c = iff(b==1,a,0);
d = sum(c,ref(day(),9));


Plot(d, "Crossindicator", colorBlack, chartLine, StyleSymbolNone);

hi i'm working with intraday data and i'm trying to get my values for "c" summed for the past X amount of days.

d= sum(c, for the past 9 days);

Any idea why my formula is not working>>

THX



umair
2013-03-10 21:45:23

  0

No solutions for this either;

a = Crossindicator(close);
b = hour() == 16;
c = iff(b==1,a,0);
d = sum(c,barssince(day() != ref(day(), 2)));


Plot(d, "Crossindicator", colorBlack, chartLine, StyleSymbolNone);



QuantShare
2013-03-11 09:42:46

  0

The calculation of "c" is based on intraday data. Would you like to sum all past "c" values for the last X days (based on intraday data)?


umair
2013-03-11 17:01:25

  0

Yes, the calculation for C is based on intraday data. My crossindicator counts how many a cross occured throughout the day. So by matching it with "B" gives me the last value for crossindicator (i.e the max value).

So to answer your second question, yes, I would like to sum up the value at 1600 for cross indicator for the past X days. "X days" should be dynamic in a sense that If X = 2, it sums up C for the past two days. I understand that I can use sum(c,300) but that only sums up X for the past 300 days. There should be a way that I can create a logic that dynamically changes the number of days I am looking at.

For example:

day1 C = 2
day2 C= 4
day3 C =5

so, sum(c,for the past 3 DAYS rather than bars)= 11




QuantShare
2013-03-11 22:44:54

  0

You are using intraday data, so using "sum(c, 300)" will sums up the past 300 bars (not days). If you are using hourly data, you can multiply the number of bars per the number of hours in a trading day to get the number of days.

If you need dynamic past values then use the "sumif" function instead. Unlike "sum", this one accepts dynamic values.




umair
2013-03-12 04:11:15

  0

"You are using intraday data, so using "sum(c, 300)" will sums up the past 300 bars (not days)." // yea i know......

I dont know what you mean by ''dynamic.'' That word can have several meanings but the context in which it's used can be important. So please refer back to my previous replies to understand the context I'm using that word in.

Back to the screener: Here's what I've came up with. It's the closest I have been to the solution that I am looking for but there is something still wrong as the system does not differentiate between different days

a = Crossindicator(close);
b = hour() == 16;
e = iff(b==1,a,0);
days = 2;
bars = 391*days;
d = sum(e,bars);

So the above should sum up 391*2 (the number of bars in two days) the values of E

the values of E for the past two days are:

day0 =17
day1= 5
day2= 10

So the solution should be 15 (sum of the past TWO DAYS)

The results given by the above are:
day0 =0
day1=0
day2=27 But then toward the end of the 2nd day the value changes to 30


Any idea why? I would appreciate if you can give me a solution (logic) this time, it seems i'm spending way too much time on this as it should be a simple logic to program!



umair
2013-03-12 06:24:07

  0

Ok, another thing i just noticed is that if i run the above filter as a screener and add a column for D it actually gives me the correct results! sum for past 2 days is 15 and sum for past 3 days is 32. So i'm not sure why when I PLOT this on a graph i'm getting different results.


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
Top 20 stocks with the highest 10 day rate of change - Current an...
Moving Average Crossovers In the Past Trading Days
Time-series Sum for the first Minutes/Hours of a Trading Day
Derivatives: Number of days until the expiration date
Stock Correlation with its Industry - Change over time

How-to Lessons
How to calculate the average of a time series using the money man...
How to screen for stocks having a high correlation with the Dow J...
How to plot two different time frames in the same chart
How to quickly download the most recent EOD data for your stocks
How to speed up watchlist and screener plug-ins when working with...

Related Forum Threads
Historical intraday data for the AEX index
Horizontal line on the intraday chart with the day's opening pric...
Thank for the Real Time Version: Interactive Brokers API question
Intraday Trading with the "Create a Trading System" tool.
Chart for 1m bars over a custom time range

Blog Posts
6 New Ways to Download Free Intraday Data for the U.S. Stock Mark...
6 ways to download free intraday and tick data for the U.S. stock...
How to Adjust the Time Displayed in your Intraday Charts
How to Backtest an Intraday Stock Trading System with EOD Ranking
How to measure market strength with the composite tool









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 © 2024 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.