Greetings,
I tried sending orders with the IBcontroller, at first it went smoothly with BUY and SELL orders as usual.
openposition = StaticVarGet(Symbol + "openposition");
if (IsEmpty(openposition)){
openposition = 0;
}
RequestTimedRefresh(1);
ibc = GetTradingInterface("IB");
Transmit = ParamToggle("Transmit to IB","OFF|ON", 0);
if (Transmit){
StartIBClockTime = Now(4);
ibc = GetTradingInterface("IB");
SetChartBkColor( colorBlue);
}
if( LastValue(Ref(BUY,-1)) AND openposition==0 AND transmit==1){
orderid=ibc.PlaceOrder( Name(), "BUY1", 100, "MKT", 0, 0, "Day", Transmit );
openposition=1;
StaticVarSet(Symbol + "openposition", 1);
}
if( LastValue(Ref(Sell,-1)) AND openposition==1 AND transmit==1 ){
ibc.PlaceOrder( Name(), "SELL", 100, "MKT", 0, 0, "Day", Transmit );
openposition=0;
}
Then I want to change it with a Scalein order and suddenly the status changes to presubmited,
openposition = StaticVarGet(Symbol + "openposition");
if (IsEmpty(openposition)){
openposition = 0;
}
RequestTimedRefresh(1);
ibc = GetTradingInterface("IB");
Transmit = ParamToggle("Transmit to IB","OFF|ON", 0);
if (Transmit){
StartIBClockTime = Now(4);
ibc = GetTradingInterface("IB");
SetChartBkColor( colorBlue);
}
//////////////////////First buy////////////////////////////
if( LastValue(Ref(BUY1,-1)) AND openposition==0 AND transmit==1){
orderid=ibc.PlaceOrder( Name(), "BUY1", 100, "MKT", 0, 0, "Day", Transmit );
openposition=1;
StaticVarSet(Symbol + "openposition", 1);
}
//////////////////////Second Buy///////////////////////////
if( LastValue(Ref(BUY2,-1)) AND openposition==1 AND transmit==1){
orderid=ibc.PlaceOrder( Name(), "BUY1", 100, "MKT", 0, 0, "Day", Transmit );
openposition=2;
StaticVarSet(Symbol + "openposition", 2);
}
if( LastValue(Ref(Sell,-1)) AND openposition==2 AND transmit==1 ){
ibc.PlaceOrder( Name(), "SELL", 100, "MKT", 0, 0, "Day", Transmit );
openposition=0;
}
what's my mistake here?
need your help and thank you