@mradtke
@TrendSurfer
Hi Matt & Michael,
Below is the code. As posted, if I run it on a large Watchlist of 100 ETFs, it will only take trades on QQQ. If I uncomment the two lines I have commented out and then comment out the logic below, and run on a Watchlist only containing SPY & QQQ, the code will take and size all trades correctly.
What I would like it to do is have the ability to run on a Watchlist of 100 ETFs, and only take trades for QQQ & SPY. This will allow me not to have to create specific, small Watchlists that are subsets of a larger Watchlist. Tomasz and Michael helped me with some array errors I had in a previous script and I think this is a legacy issue but I cannot get to the root of it.
Thanks,
Mike
Max_SPY_Exposure = Param("Max SPY Exposure", 70, 0, 100);
Min_SPY_Exposure = Param("Min SPY Exposure", 30, 0, 100);
Safe_Asset_Trigger = ParamStr("Safe Asset Symbol", "SPY");
Risky_Asset_Trigger = ParamStr("Risky Asset Symbol", "QQQ");
Symbol_Name_1 = ParamStr("Investment - Symbol Name 1", "SPY");
Symbol_Name_2 = ParamStr("Investment - Symbol Name 2", "QQQ");
SPY_Close = Foreign(Safe_Asset_Trigger, "C");
QQQ_Close = Foreign(Risky_Asset_Trigger, "C");
ShortTerm=ROC(SPY_Close,20);
LongTerm= ROC(QQQ_Close,20);
Buy1=ShortTerm >= Longterm;
Buy2=ShortTerm <= Longterm;
Sell1=ShortTerm < Longterm;
Sell2=ShortTerm > Longterm;
BuyPrice=SellPrice=C;
SPY_Max=Max_SPY_Exposure;
SPY_Min=Min_SPY_Exposure;
QQQ_Max=100-SPY_Min;
QQQ_Min=100-SPY_Max;
n = Name();
//if (n== Symbol_Name_1) SetPositionSize( IIF( Buy1, SPY_Min, SPY_Max ),spsPercentOfEquity);
//if (n== Symbol_Name_2) SetPositionSize( IIF( Buy1, QQQ_Max, QQQ_Min ),spsPercentOfEquity);
if (n== Symbol_Name_1 OR n== Symbol_Name_2 )
{
if (n== Symbol_Name_1) SetPositionSize( IIF( Buy1, SPY_Min, SPY_Max ),spsPercentOfEquity);
if (n== Symbol_Name_2) SetPositionSize( IIF( Buy1, QQQ_Max, QQQ_Min ),spsPercentOfEquity);
Buy= IIf(Buy1, Buy1, Buy2);
Sell=IIf(Ref(Buy1,-1), Sell1,Sell2);
}
ApplyStop( stopTypeNBar, stopModeBars, 1);