I want to allocate different fund to stock by different indicator like ATR , so I write this.
for(i=0;i<BarCount;i++)
{
atrv=ATR(10);
if(atrv[i]==0)
weight[i]=100;
else
weight[i]=300;
}
if( Status("action")== actionPortfolio)
{
// retrieve the interface to portfolio backtester
bo = GetBacktesterObject();
bo.PreProcess();
CurrentOpenqty=0;
for ( bar = 0; bar < BarCount; bar++ )
{
CurrentPortfolioEquity = bo.Cash;
CurrentOpenqty=bo.GetOpenPosQty();
for ( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( bar ) )
{
{
if( CurrentOpenqty < (posqty) )
{
sig.PosSize = -(weight[bar]/posqty);
}
}
}
bo.ProcessTradeSignals( bar );
}
bo.PostProcess();
}
}
but the value what I get is always (atrv[i]=0) weight=100, and actually it’s not zero.
How can I modify it to let it work correctly?