hi do you know What's WRONG? the Errors occur at the second half of the code text.
Thanks for your help!
Error messages from AFL editor:
-Subscript out of range. you must not access array elements outside 0..(BarCount-1) range.
-COM object variable is not initialized or has invalid type(valid COM object handle required)
-Syntax error
//SETTING
A=13200;
highentry=50;
highexit=100;
highstop=100;
cancelsellc1=200;
cancelsellc2=200;
//param trigger button to reset status
resetStatus = ParamTrigger("resetStatus","resetStatus");
//START
DateNumNow = Now(3);
DN = DateNum();
TN = TimeNum();
//check if order placed
OrderPlaced = StaticVarGet("OrderPlaced");
if(resetStatus)
{
StaticVarSet("OrderPlaced",0);
}
OrderPlaced = StaticVarGet("OrderPlaced");
//check if order is triggered, place order if condition fullfiled
if( (IsEmpty(OrderPlaced) OR OrderPlaced==0) )
{
ibc = GetTradingInterface("IB");
IBcStatus = ibc.IsConnected();
if( IBcStatus )
{
// place order
LimitSell = A+highentry;
parentIDShort = ibc.PlaceOrder(Name(), "SELL", 1, "LMT", LimitSell, 0, "DAY", False );
ibc.PlaceOrder(Name(), "BUY", 1, "LMT", LimitSell-highexit, 0, "DAY", False, 1, "", parentIDShort );
ibc.PlaceOrder(Name(), "BUY", 1, "STP", 0, LimitSell+highstop, "DAY", True, 1, "", parentIDShort );
}
}
// PART 2222222222222222222222conditonal cancel sell order
Lastprice=C;
Condition1 = Lastprice == (A+cancelsellc1);
Condition2 = Lastprice == (A+cancelsellc2);
Cancel=0;
for ( i = 1; i < BarCount; i++ );
{
if (Condition1);
{
if (Condition2);
{
StaticVarSet("Cancel",1);
ibc.CancelOrder(parentIDShort);
}
}
}
Cancel=StaticVarGet("cancel",0)
Thanks for your help!
Error messages from AFL editor:
-Subscript out of range. you must not access array elements outside 0..(BarCount-1) range.
-COM object variable is not initialized or has invalid type(valid COM object handle required)
-Syntax error
//SETTING
A=13200;
highentry=50;
highexit=100;
highstop=100;
cancelsellc1=200;
cancelsellc2=200;
//param trigger button to reset status
resetStatus = ParamTrigger("resetStatus","resetStatus");
//START
DateNumNow = Now(3);
DN = DateNum();
TN = TimeNum();
//check if order placed
OrderPlaced = StaticVarGet("OrderPlaced");
if(resetStatus)
{
StaticVarSet("OrderPlaced",0);
}
OrderPlaced = StaticVarGet("OrderPlaced");
//check if order is triggered, place order if condition fullfiled
if( (IsEmpty(OrderPlaced) OR OrderPlaced==0) )
{
ibc = GetTradingInterface("IB");
IBcStatus = ibc.IsConnected();
if( IBcStatus )
{
// place order
LimitSell = A+highentry;
parentIDShort = ibc.PlaceOrder(Name(), "SELL", 1, "LMT", LimitSell, 0, "DAY", False );
ibc.PlaceOrder(Name(), "BUY", 1, "LMT", LimitSell-highexit, 0, "DAY", False, 1, "", parentIDShort );
ibc.PlaceOrder(Name(), "BUY", 1, "STP", 0, LimitSell+highstop, "DAY", True, 1, "", parentIDShort );
}
}
// PART 2222222222222222222222conditonal cancel sell order
Lastprice=C;
Condition1 = Lastprice == (A+cancelsellc1);
Condition2 = Lastprice == (A+cancelsellc2);
Cancel=0;
for ( i = 1; i < BarCount; i++ );
{
if (Condition1);
{
if (Condition2);
{
StaticVarSet("Cancel",1);
ibc.CancelOrder(parentIDShort);
}
}
}
Cancel=StaticVarGet("cancel",0)