Buy = 0;
Sell= 0;
Short = 0;
Cover = 0;
B=0;
CB = 0;
TargetBuy = Param("Target Buy", 1.2168, 0.00001, 140, 0.00001);
Plot( TargetBuy, "Target: "+ TargetBuy, ParamColor("Target Color", colorGreen), ParamStyle("Target Style", styleLine));
Buy = Ref(H,-1) > Ref(TargetBuy, -1) & C < TargetBuy;
ibc = GetTradingInterface("IB");
if( ibc.IsConnected() )
{
if (ibc.GetPositionSize (Name()) == 0)
{
if( LastValue (Buy))
{
do
{
ibc.PlaceOrder (Name(), "Buy", 20000, "Mkt", targetbuy, 0, "GTC", False);
CB++ ;
} while (CB > 1);
}
}
}
Hi Team,
I have used the above code to test sending Buy in instruction to IB, but the result is the Buy in order was resending repeatedly. I just want to limit the number of time for sending the order to IB. Please help.
Thanks so much.
Peter