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