Unfortunately, this is not possible in AFL I am afraid. I tried the following but does not work either because sometimes it gives wrong signals.
Sell=C<(1-StopLoss/100)*ValueWhen(Buy,Ref(O,1),1) I wonder if anybody managed to build proper trading system based on EOD data in Amibroker, which can be used in real trading. If your indicators are based on Close then you have to trade on next day Open, in which case you need to use Settradedelays and you are immediately dead as AFL does not support this. If you want to use combined StopLoss and Profittarget exits together, it does not work. If you want to use combined Trailing stop and PT exits, it does not work. You can find couple of useless examples in AFL Function Reference under ApplyStop, which has nothing to do with real trading. I am really disappointed with Amibroker and AFL. I have been programming it for 2 years so I know what I am talking about. You cannot find out what the reason of the bad exit signals are. It is like a black box. --- In [email protected], "zozuzoza" <[EMAIL PROTECTED]> wrote: > > Hi, > > I would like to apply a stoploss on next day OPEN when PREVIOUS day > CLOSE hits stop and Sellprice=Open. In the AFL library, I could only > find the solution for > "Scenario 3: > you trade on next day OPEN and want to exit by stop on OPEN price > when PREVIOUS day H-L range hits stop" > > This is almost good for me except I want the Applystop function to > check the PREVIOUS day Close instead of the H-L range. > > The settings I would like to use is as follows. > SetOption("AllowSameBarExit",1); > SetOption( "ActivateStopsImmediately", 1); > SetTradeDelays( 1, 1, 1, 1 ); > BuyPrice=O; > SellPrice=O; > > I am stucked. Could anybody help me please how I can do it. > > Thank you. >
