You need to define your buy and sell signals within the AFL code and then enter trades via trading interface once the signal is generated. I posted some code yesterday that may be generally helpful.
Your sell condition cannot be entered as a trailing stop order. Instead you should define a sell condition in AFL, that triggers a sell when the when the price of current bar dips below the low of the previous bar. You can then enter the trade via the IB interface when LastValue (SELL) is true. --- In [email protected], "dralexchambers" <[EMAIL PROTECTED]> wrote: > > Hi - I am looking into automating AB with Interactive Brokers. I have > been going through the documentation supplied with AB on this. > > Is it possible to code an order that does the following from > Amibroker: > > BUY = Cross( Ref(MACD(),-1), Ref(Signal(),-1) ); > > 1. This buy signal is only triggered when the current candle/bar has > closed (ie. the buy signal is not triggered when the candle is still > forming) > > SELL = Trailing stop loss > > 2. The trailing stop I need is as follows - the stop loss to be > raised to the Low of the candle just formed, eg: > > 5 min chart: > > 14:25-14:30 candle low = $100. > > Time now = 14:32. Current low = $90. Stop loss is $100, because this > 5 min candle is still forming, and the low of the 14:25-14:30 candle > is used > > Time now = 14:35, new candle starts. Low of 14:30-14:35 candle = $85, > so stop loss is now $85. > > > Can this be done - if so, how? > Thanks, > Alex >
