hi,
 
since you check for the positionsize this should not happen.  Each time the active chart is updated it will send this order again. Once it is executed the positionsize should change to zero. So it seems to me that two orders (or chart refreshes) follow eachother before the positionsize change is known to the system.  It does not sound very scientific but I see strange things happening (which should not be able to occur) with the IBc as well that I can't explain.  I got a faster internet connection and many of my problems have disappeared. But still strange things happen. Especially if Amibroker is in the process of backfilling data en the code below can not perform a calculation because there is not sufficient data. The software enters conditional statements that should not be possible. Still it does ....
 
regards, Ed
 
 
 
 
----- Original Message -----
From: rhoemke
Sent: Saturday, September 30, 2006 7:24 PM
Subject: [amibroker] IBC sending two orders, but should send only one

Hello,
i got this code for putting automatic Stop when detecting an open
position, but it sends two stop orders at once.

someone who can help me?

thank you in advance
Robetr

//Auto-Trailstop

L_Trailstop = Ref(L,-1); //or whatever

S_Trailstop = Ref(H,-1); //or whatever

ibc = GetTradingInterface("IB");

if(ibc.isconnected())

{

Position = ibc.getpositionsize(Name());

if( Position < 0 )

{

OrderID = StaticVarGetText("OrderID" + Name());

OrderID = ibc.ModifyOrder(OrderID, Name(), "BUY",
-Position, "STP", 0, LastValue(S_Trailstop), "DAY", False, TickSize*100);

StaticVarSetText("OrderID" + Name(), OrderID);

}

if(Position > 0 )

{

OrderID = StaticVarGetText("OrderID" + Name());

OrderID = ibc.ModifyOrder(OrderID, Name(), "SELL",
Position, "STP", 0, LastValue(L_Trailstop), "DAY", False, TickSize*100);

StaticVarSetText("OrderID" + Name(), OrderID);

}

}

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html






SPONSORED LINKS
Software support Small business finance Business finance online
Business finance training Business finance course

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to