- Joined
- 30 June 2007
- Posts
- 7,200
- Reactions
- 1,225
Re: Amibroker exits
You mean you want to sell for L<=Ref(L,-1) only if it happens the day after buying?... otherwise nbar=3?
If so:
Buy = ROC(C,1)>5; // change to your buy rules
Sellprice = Iif(ref(Buy,-1),Ref(L,-1),C); // if you bought yesterday, then sell if L<=Ref(L,-1), otherwise..
Sell = Sellprice>=L and Sellprice<=H;//
Applystop(stoptypenbar,stopmodebars,3);
Thanks very much for the help, GB.
The NBar stop part is not working correctly. I am getting exits marked as 'n-bar' in the correct places, but the actual exit, the exit price, is the previous low, the same as the stop-loss exits. I'm trying to get the second exit to occur at the close of the third day.
You mean you want to sell for L<=Ref(L,-1) only if it happens the day after buying?... otherwise nbar=3?
If so:
Buy = ROC(C,1)>5; // change to your buy rules
Sellprice = Iif(ref(Buy,-1),Ref(L,-1),C); // if you bought yesterday, then sell if L<=Ref(L,-1), otherwise..
Sell = Sellprice>=L and Sellprice<=H;//
Applystop(stoptypenbar,stopmodebars,3);