hello,

this is a work in progress for me...but you can get  idea from below code.

// CODED BY PADHU ON 08/08/2007

ibc = GetTradingInterface("IB");

STOP=1.3665;

LIMIT=1.3705;

BuySTOP=1.3695;

TICKS=1;

JPY_TICKS=0.01;

Broker_Symbol="EUR.USD-IDEALPRO-CASH";

Quantity=25000;

//

ibc = GetTradingInterface("IB");

if( ibc.IsConnected() ) // check if connection to IB was successfull

{

// BUYSTOP to enter a long position followed by a TRAILINGSTOP LOSS ORDER

//parentID=ibc.PlaceOrder(Broker_Symbol,"Buy", Quantity, 
"STPLMT",Limit,Buystop, "GTC", False,100,"" ); // place order but do not 
transmit yet

// ibc.PlaceOrder(Broker_Symbol,"Sell", Quantity, "TRAIL",0,STOP, "GTC", True, 
100, "", parentID);

}

if( ibc.IsConnected() ) // check if connection to IB was successfull

{

//parentID = ibc.PlaceOrder(Broker_Symbol, "Buy", Quantity, "STP", 0, BuySTOP, 
"GTC", False,TICKS ); 

// ibc.PlaceOrder(Broker_Symbol, "SELL", Quantity, "LMT", LIMIT, 0, "GTC", 
False, TICKS, "", parentID ); 

// ibc.PlaceOrder(Broker_Symbol, "SELL", Quantity, "STP", 0, STOP, "GTC", True, 
TICKS, "", parentID );

// Bracket order // place order but do not transmit yet

//parentID = ibc.PlaceOrder("GBP.JPY-IDEALPRO-CASH", "SELL", 25000, "STP", 0, 
238.55, "GTC", False ); 

//ibc.PlaceOrder("GBP.JPY-IDEALPRO-CASH", "BUY", 25000, "LMT", 238.00, 0, 
"GTC", False, 100, "", parentID ); 

//ibc.PlaceOrder("GBP.JPY-IDEALPRO-CASH", "BUY", 25000, "STP", 0, 239.25, 
"GTC", True, 100, "", parentID );



//LimitBuy = D1+A1;

//parentIDLong = ibc.PlaceOrder(Name(), "BUY", 1, "LMT", LimitBuy, 0, "DAY", 
False );

//ibc.PlaceOrder(Name(), "SELL", 1, "LMT", LimitBuy+B1, 0, "DAY", False, 1, "", 
parentIDLong );

//ibc.PlaceOrder(Name(), "SELL", 1, "TRAIL", C1, C1, "DAY", True, 1, "", 
parentIDLong );



// BUYSTOP WITH TRAILINGSTOP ORDER

//parentIDLong=ibc.PlaceOrder("EUR.NZD-IDEALPRO-CASH", "BUY", 25000, "STPLMT", 
1.9498,1.9488, "GTC", False,1,"" ); // place order but do not transmit yet

// ibc.PlaceOrder("EUR.NZD-IDEALPRO-CASH", "SELL", 25000, "LMT",1.9510, 0, 
"GTC", False,1,"",parentIDLong); 

// ibc.PlaceOrder("EUR.NZD-IDEALPRO-CASH", "SELL", 25000, "TRAIL",1.9450, 
1.9450, "GTC", True, 1, "", parentIDLong); 



  ----- Original Message ----- 
  From: dralexchambers 
  To: [email protected] 
  Sent: Saturday, September 22, 2007 10:42 AM
  Subject: [amibroker] Bracket Order with IB Auto-Trading interface


  Hello - I am trying to create a Bracket Order with the IB Auto-
  Trading interface. This would be like this:

  - Buy if price reaches x
  - If price reaches x and buy order triggered, enter a stop loss sell 
  order at y

  Can anyone help with how I would do this?

  Thank you,
  Alex



   

Reply via email to