I'm trying to say "sell if ROC(o,1)>0 or applystop(1% profit)". Same bar entry/exit is disallowed.
I have tried using SetStopPrecedence, but I need a way to make the Sell line take precedence over the Applystop, otherwise I am looking ahead.
SetStopPrecedence(stopTypeProfit, stopTypeNBar, stopTypeLoss, stopTypeTrailing, );
SellPrice = o;
Sell = ROC(o,1)>0;
Could someone please tell me the ciorrrect way to do this?
Would it be possible to have something like:
SetStopPrecedence(*Sell Line Condition*, stopTypeProfit, stopTypeNBar, stopTypeLoss, stopTypeTrailing );
Or is there an easier way to achieve my goal? Thanks very much for the help.
SellStopPrecedence has absolutely nothing to do with regular exits (i.e. via Sell variable) http://www.amibroker.com/f?setstopprecedence
You really need to read the manual about ApplyStop http://www.amibroker.com/f?applystop
There are scenarios that are supported and described in great detail. Read those scenarios. Your scenario is listed as scenario 1. You don't need to call SetStopPrecedence at all. All that is required is described in manual.
I think my particular situation falls outside the examples given. I'd like the sell variable to trigger ahead of the profitstop when they occur on the same bar.
As I wrote, SetStopPrecedence does NOT affect regular exits. It only changes the ordering of stops (loss, trailing, N-bar, profit) that occur on same bar. You've got only one stop so calling SetStopPrecedence has absolutely ZERO effect.
As explained in manual: http://www.amibroker.com/f?applystop it is "ActivateStopsImmediately" setting that affects when stops are executed with regards to regular signals. If it is set to TRUE, regular signals are triggered first.
My final settings (for anyone else playing along at home).
Buy = cond;
SellPrice = o;
Sell = ROC(o,1)>0 ;
ApplyStop(stopTypeProfit,stopModePercent,1,exitatstop=1,volatile = true,ReEntryDelay = 5);