Hi,
I want to control the number of trades which can be executed during a live trading session. I normally use scan option and run a watchlist which has multiple stocks.
I want the trade limit in exploration / scanning (NOT BACKTESTING).
Not sure what error I am committing, could someone highlight please.
I have listed below my code.
SetChartOptions(0,chartShowDates);
(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
E1=EMA(C,10);
E2=EMA(C,50);
LE=C>E1 AND E1>E2;
LX=C<E2;
bflag=sflag=0;
Buy=Sell=0;
newday=IIf(DATENUM()!=Ref(DATENum(),-1),1,0);
for (i=1 ;i<BarCount;i++)
{
if (newday[i]==1)
{
TradeNo=0;
StaticVarSet("MyTrade",TradeNo);
}
else
{
TradeNo=StaticVarGet("MyTrade");
}
if (LE[i]==1 AND bflag==0 AND TradeNo<=3)
{
Buy[i]=1;
BFlag=1;
TradeNo=TradeNo+1;
StaticVarSet("MyTrade",TradeNo);
}
if (LX[i]==1 AND BFLAG==1)
{
Sell[I]=1;
BFLAG=0;
}
}
Please help.
Thanks & Regards
Madhan.