Click here to Login





                                                   Replacing value for the last 100 bars (end of day data)

  0

0
Christophe
2017-02-07 05:23:35


Hi all,

I have two questions regarding replacing value:
(I could not find an answer on the site)

1. I have a stock (ie. MSFT) and I would like to replace its value for the last 100 bars by the value of another stock (ie. SP500). I assume I have to create a composite based on MSFT, except for the last 100 bars where it will be SP500 value. Do you know how if it is feasible in Quantshare?

2. Same but except that instead of having SP500 value for the last 100 bars, I would like to replace MSFT value by SP500 rate of change applied to MSFT stock for the last 100 bars. I also assume that I have to create a composite.

Here is an example what the composite (C1) would look like:

Before the last 100 bars, the composite C1 has MSFT value.
At bar -102 of C1, C1 has MSFT value
At bar -101 of C1, C1 has MSFT value
At bar -100 of C1: if SP500 moves up 1%, I would like C1 to be up by 1%.
At bar -99 of C1, if SP500 moves up 2%, I would like C1 to be up by 2%
At bar -98 of C1, if SP500 moves down 1%, I would like C1 to be down by 1%

Do you know how if it is feasible in Quantshare?

I assume that considering its complexity, it has to be done in composite instead of indicators.

Please let me know if my request is not clear.

Thanks for your help.

Christophe



QuantShare
2017-02-07 07:02:41

  0

Hi Christophe,

Yes it can be done using the composite tool or using the script editor (Tools -> Script Editor).
Probably easier with the composite tool.

If you just want to display the data (not creating a ticker symbol), you can use QS formula to plot that.

Example:

pass = (TotalBars() - count()) < 100;
o = iff(pass, getseries("spy", open, LastData), open);
c = ....
h = ....
l = ...
PlotCandleStick1(o, h, l, c, "", colorRed, StyleSymbolNone);





Christophe
2017-02-09 07:20:40

  0

Hi,

Thank you for your answer. Based on your input, I was able to create a composite to replace value:

temp1 = GetSeries('^GSPC', Close);
temp2 = GetSeries('^FCHI', Close);
pass = (TotalBars() - count()) < 100;
composite = iff(pass, temp2, temp1);

I have two questions:

1. pass = (TotalBars() - count()) < 100; is Quantshare language. How can it be written in C? (for script)


2. Is there a way to add to a composite the previous value of the composite?

Example: In this case, it does not add the previous composite value. The result is always 3
composite = 1;
temp1 = 2;
composite = ref(composite,1) +temp1;


Thank you for your help.

Christophe



QuantShare
2017-02-09 11:55:22

  0

1/ Yes, QuantShare language. This is how composites are created. You can create advanced ones using C# based script by clicking on the script button next to the formula editor.

Check our documentation for more information.

2/ You should create a C# script for that



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
Time-series Sum for the first Minutes/Hours of a Trading Day
Screen for finding potential high volume momentum growth for the ...
Stop Loss for the N-first Trading Bars only
% bars in last N trading days where stock close price increased
Adaptive Trading System - Percent Winning Trades for the Last N-D...

How-to Lessons
How to quickly select stocks based on the last value of a databas...
How to display the number of stocks per day for different RSI gro...
How to plot the number of stock tweets per day
How to add future bars to plan for market scenarios
How to quickly download the most recent EOD data for your stocks

Related Forum Threads
How to get the last day of the month in C#
Top gainers for the day
Previous day value for indicator in Screener?
Quality of fit of CLOSE to linear regression for last n bars.
Speed of script execution for symbols with many bars

Blog Posts
How to Select the Best Market Indicator for your Trading System
How to download the history of dividend payments for stocks in th...
Custom Shortcuts - Move a Chart to Display the Last Quotes/Data
6 New Ways to Download Free Intraday Data for the U.S. Stock Mark...
Basic trading system implemented using the money management 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 2021 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.