[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Stuck on simple breakout and reverse using applystop



PureBytes Links

Trading Reference Links


Hi,

I'm completely stuck!

I'm trying to write a simple breakout and reverse system. 
1) Some code to determine initial breakout price, up or down.
2) Apply stoploss and limit exit to first trade. (No problem)
3) if price reaches acceptable level, move stoploss to break even. (No problem)
4) if price hits stoploss or break even stoploss, reverse the trade with new different stoploss and limit exit (Big headache).

The below works fine for the initial direction.
But I'm completely stuck on how to set up the reverse trade.

StopLoss = 0.0030;
BrkEvnBuff = 0.0025;
LimitExit    = 0.0150;
ReverseStop = 0.0050;
ReverseLimit = 0.0110;
BOEnd = 080000;

Buy = H >= BOHigh;
Short = L <= BOLow;

// Determine Break Even & move the StopLoss
BBEvn1 = H >= BOHigh + BrkEvnBuff;
BBEvnSig1 = Flip(BBEvn1,TimeNum()==BOEnd);
Stoploss = IIf(BBEvn1 == 1, 0.00001,Stoploss);

SBEvn1 = L <= BOLow - BrkEvnBuff; 
SBEvnSig1 = Flip(SBEvn1,TimeNum()==BOEnd);
Stoploss = IIf(SBEvnSig1 == 1, 0.00001,Stoploss); 

ApplyStop(stopTypeLoss,stopModePoint, Stoploss,ExitAtStop = 1,Volatile = True);
ApplyStop(stopTypeProfit,stopModePoint, LimitExit,ExitAtStop = 1,Volatile = True);

Where do I put the code for the reverse trade - Is it before the apply stop or after the apply stop?
Should I try to put all the buy/short code before the applystop or have the reversal code after applystop? Had the great idea of using sell==2 to find out a previous max loss trade and the do the 2nd trade and applystop 2nd type but of course the first applystop takes priority!!!
I'm stuck because I can't just do a short = sell because of the limit exit.
The reverse stop & limit exit depends on if an initial trade being taken and how it was exited. How do I determine all that?

Help!!!
I'm sure AB can do this but I just can't get my head around it!

Thanks





------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/