I'm wanting to use the indicator "supetrend" in a strategy ( https://www.quantshare.com/item-1038-supertrend-indicator)
Basically I'm using an external symbol XJO as a marketiming input, if the index is above it's supertrend then its ok to go long on stocks
However, I'm a bit confused (newbie) on how to calc the supertrend of this external symbol , since I don't know how to incorporate the symbol into the formula
ie how do I calc the supertrend of XAO when the supertrend indicator doesn't take a symbol input ?
This is what I started to code but I know its not right . I want to calc the supertend of XJO and also the supertrend of individual stocks before I buy
stLenMT=10;
stFactMT=3;
stLen=10;
stFact=3;
// marketiming based on XAO holding above its supertrend
MTindex =GetSeries('XAO', Close);
MTbuy= MTindex > supertrend(stLenMT, stFactMT);
// buy when stocks cross up thru their own supertrend and overall marketiming is a buy
buy = cross(close, supertrend(stLen, stFact)) and MTBuy ;
This indicator cannot be used to calculate other symbol supertrend. You need to update the C# formula of the "supertrend" indicator, add a new parameter (that takes the close series for example) and use that series instead of the "close" series of the analyzed security.
thanks for the reply. To implement your suggestion is that easy to do ? The supertrend indicator references a function , which is copied below. Are you able to show me how to "hardcode" for symbol XJO.AX ?
edits were done as you suggested , but I've hit an error . Please see here
https://www.dropbox.com/s/xc8zwf58ys9gja2/2017-04-23_11-43-22.png?dl=0
appears to not like the statement
VectorD close = close;
Also, its not clear to me how I actually ''hardcode'' the symbol into this ? I guess I create a param to input the symbol string, but not sure what to do with it after that
VectorD close = close1; // where "close1" is the name of one parameter
Since you are passing the close, open, high and low of a specific security, there is no need to pass the symbol name.
For the "close1" parameter for example, you should pass in QS language: Getseries("GOOG", close)
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.