Click here to Login




Day Trading: A trading system that combines intraday and EOD data

Updated on 2011-12-14





Combining intraday and end-of-day data in a trading system is something easy to perform in QuantShare. Some read-to-use functions allow you to get intraday data when working in EOD mode and EOD data when working in intraday mode. In case your needs are more complex, there is always the custom functions creator tool, which basically allows you to implement any function not matter how complex and advanced it is.

The strategy we will describe here may be used as an example for day traders who want to implement trading systems using QuantShare.

This is the second post of a series started few weeks ago. You can find the first post here: Example of a trading system implemented in QuantShare Software. There, you will also find instructions on how to create a trading system in your favorite quant trading software.


Day Trading System Settings

The time frame is set to 5 minutes and the maximum number of positions is set to 10.

- Update your trading system then update the "Number of positions" field
- Select "Symbols & Dates" tab then click on the link located next to "Select a time frame". In the list, select "5m" (5 minutes).


Trading System Buy Rules

Rule 1: Buy if the open price of today session is 1% lower than yesterday's close and if the stock price increases and stays in positive territory before the first trading hour.
Rule 2: Buy only if the daily RSI (Relative strength index) is higher than 70

How to get the open price of today session:

The open price of today can be obtained using the "HistoPrice" function. We specify the field type in the first parameter and the lag value in the second. By specifying zero as "Lag" value, we obtain data for the current trading day.

a = HistoPrice(_open, 0);

How to get yesterday's close:

"HistoPrice" is also used to get yesterday's close. "_close" field is set in the first parameter and "1" in the second one (lag).

a = HistoPrice(_close, 1);

How to determine if the current bar is within the first trading hour:

a = hour() * 60 + minute() < (10*60+30);

In the above instruction, we calculate the number of minutes since date start and then compare it to the number of minutes from date start to "10:30 am". If the first component is lower than the second one then we are still in the first hour of the trading session.

How to get the daily RSI while working with an intraday period:

The easier way to perform calculation based on EOD data while working with intraday quotes is by using the "TimeframeApply" function. By simply entering a period and a time-series, this function will transform this time-series in the specified period and it will return the result in compressed format (No date synchronization with the current period). To adjust or synchronize the result with the current data, we must use the "TimeframeDecompress" function.

Another important thing here is that we must add a minus (-) sign to the period to reference EOD data. Otherwise, the function will continue using the current intraday data/quotes.

Note that when working with daily data, then minus sign allows us to reference intraday data.

The easier way to understand and visualize the output of these functions is by plotting them on a chart:

- Open a 5-minute chart then type the following formula:

a = TimeframeApply(-1, close);
a = TimeframeDecompress(a);
Plot(a, "Daily Prices", colorBlack, chartLine, StyleSymbolNone);


- Add "//" before the second line to see what I mean by compressed format

Back to our trading system, in order to get the daily RSI value type:

a = TimeframeDecompress(TimeframeApply(-1, rsi(14)));

Note: It is necessary that you download EOD data for the analyzed securities


Trading System Sell Rules

This day trading system contains one single rule, which is to sell any position or trade after four hours.

How to exit a trade after four hours:

This can be accomplished using an "N-Bar Stop". Since we are working with 5-minute period, four hours represent a total of 48 bars (12 * 4).

To set the stop rule programmatically, type the following line:

SetSimStop(_StopNBar, _Point, 48, 0);


Complete Trading System Formula

rule1 = HistoPrice(_open, 0) < HistoPrice(_close, 1) * 0.99;
rule2 = hour() * 60 + minute() < (10*60+30) and close > HistoPrice(_close, 1);
rule3 = TimeframeDecompress(TimeframeApply(-1, rsi(14))) > 70;

buy = rule1 and rule2 and rule3;

SetSimStop(_StopNBar, _Point, 48, 0);



This day trading system is simply an example to show you how implement trading ideas in QuantShare and it is not intended to create a profitable strategy. This is why we will not show you any report or backtesting result.











3 comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Lock, Link and Undock your Charts
Posted 230 days ago

QuantShare
Previous Posts

More Posts

Back







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 2019 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.