Hello friends, I'm having difficulty coming up with the code that will allow me to adjust position sizes while remaining in the market all the time. What I'm trying to do is just follow a standard say typical 80% equity 20% fixed income portfolio while my rules say to be risk-on, and then switch to a more conservative portfolio, say 20% equity 80% fixed income when my rules turn to risk-off. So I'm really just wanting to adjust the position sizes according to the model, rather than buying and selling whole positions. I've been successful getting the risk on side of the trade to work with the case statement (provided by one of the contributors here I'm sure). However, I'm having difficulty getting it to adjust the position sizes on a move to risk-off which I had been calling 'closingtrade' (a misnomer now).
this is what I have so far:
/*openingtrade=some risk-on condition*/
/*closingtrade=/*some risk-off condition*/
openingtrade=Flip(openingtrade,closingtrade);
closingtrade=Flip(closingtrade,openingtrade);
Buy=1;
Sell=0;
ps=0;
if (openingtrade==1)
{
switch(Name())
{
case "VFIAX": ps=38.6; break;
case "VEXAX": ps=8.4; break;
case "VTMGX": ps=23.5; break;
case "VEIEX": ps=7.9; break;
case "VBIRX": ps=6.1; break;
case "VBILX": ps=3.7; break;
case "VBLLX": ps=4.1; break;
case "OMBAX": ps=3.8; break;
case "VTABX": ps=0; break;
}
}
else
{
switch(Name())
{
case "VFIAX": ps=10; break;
case "VEXAX": ps=10; break;
case "VTMGX": ps=10; break;
case "VEIEX": ps=10; break;
case "VBIRX": ps=10; break;
case "VBILX": ps=10; break;
case "VBLLX": ps=10; break;
case "OMBAX": ps=10; break;
case "VTABX": ps=10; break;
}
}
SetPositionSize(ps,spsPercentOfEquity);
Thank you for any help or guidance! The error I'm getting is Error 6: Condition in if,while, for statements has to be numeric or boolean...