Thank you for all your help. It is very much appreciated.
I am looking at a system where if the Momentum conditions are met but the stock price is below its 200 day moving average, I want to buy the short term treasury ETF SHY.
Next month, if all the conditions including the moving average, then SHY is sold and the selected stock is purchased.
Is there any way to code it without going into money management add on?
Are you referring to the "stock price" of "SHY" (below its 200 day...) ?
Regarding the "Next month" part, you would need to use the money management script as the strategy formula is used to generate signals only and thus doesn't know which stocks/ETFs where bought or not.
Say I am looking at SPY, QQQ, DIA and MDY. Supposed MDY and QQQ have the highest momentums. However, MDY is below its own 200 day MA and QQQ is above its own 200 day SMA. Then, I want to purchase QQQ and SHY.
You will need to rank all the securities (including SHY). In the ranking formula, you add a condition so that if an ETF is below its 200 bar MA it gets a value of 0.
Example:
f = perf(close, 25);
f = iff(close > sma(200), f, iff(stringequal(name(), "SHY"), f, 0));
a = comp(f, "rank") <= 2;
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.