help with understanding buy/sell orders

#1
hello, first of all I would like to welcome everybody. I am new to amibroker and trying to learn afl unfortunatelly that would be my first programming language so I have some difficulties with understanding some basic concepts. All written experts which I saw have for example such condition for buy trigger "Buy = Cross(RSI(C,6),15)" . I understand that the code works this way: if rsi which uses close prices and lookback period 6 bars crosses price 15 it will buy the first ask price. The code will execute only on 1 stock and it does not look on bid and ask prices. What I am trying to achieve is to generate a buy signal on instrument B (only on instrument) and a sell signal on instrument C (only on C).
The code should check the best bid price on instrument A, then the price will go into a model, and let’s say that the output from the model would be to place an order 0,5 usd higher then the price on instrument A (let’s say that the price of instrument B is irrelevant) on instrument B on the bid side and when the order will be filled then it should sell instrument C on the best bid price. So in other worlds Bid price of instrument A would be a reference for placing an order on instrument B. If the price of instrument A will change then the order on instrument B should be modified if the order on instrument B will get filled then afl should sell instrument C for any price. How represent that idea with an afl code. I realize that the modifying part will be related with my api plugin.
Thank you so much in advance Tom
 

colion

Active Member
#2
The Cross() expression is wrong unless you use RSIa(). As for having the signal apply to different symbols you will probably have to write some code with all of your conditions using Foreign() and/or SetForeign() functions to specify A, B, C, symbols.
 

Similar threads