AFL code for N-Bar and Trailing stop order placement in Interactive Brokers

Hi @Ghanshyam_Singh,
ApplyStop is AFL code to simulate stops, not to execute them. That is, it doesn't magically send orders to IBKR.
First use Equity(1) (possibly with other arguments) to update buy/sell/short/cover arrays according to your ApplyStop() instructions. stopTypeNBar stops are not special. Second write code to send orders to TWS via IBController. This code should execute if and only if Buy/Sell/Short/Cover is true. For more details search this forum & the knowledge base e.g:

Really everything you need is here in this forum, in the kb or in the manual.
Cheers.

PS: please use code button to include AFL code.
code button amibroker forum 2

2 Likes