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

Coding a breakout system



PureBytes Links

Trading Reference Links

Hi, All: 

Crack programmer I am not. I am trying to code a simple breakout 
system, but when I try to invoke it in AA, I get no trades at all. 
Obviously, something's wrong, but I can't figure it out. The code I 
wrote is given below. I want to buy when the high exceeds the 
highest high over the last HH periods and then sell (exit) when the 
low declines below the lowest low over the last LL periods. I also 
want to set a hard stop at 2*ATR(15) below my entryprice, which 
should remain fixed throughout the trade. Can someone look over the 
code below and tell me what is wrong? I'd really appreciate it. It's 
probably something very simple and stupid. 

HH=Optimize("HH",20,20,60,4);
LL=Optimize("LL",10,10,40,4);
pds=15;
UpBreak=HHV(H,HH);
BuyCond=Cross(H,UpBreak);
Buy=Ref(BuyCond,-1);
BuyPrice=Open;
FixedBuyPrice=ValueWhen(Buy,Open);
Capital = 100000;
Risk=0.01*Capital;
PositionSize=Risk/(2*ATR(pds))*FixedBuyPrice;
DnBreak=LLV(L,LL);
ApplyStop(0,2,2*ATR(pds),1);
SellCond=Cross(DnBreak,L);
Sell=Ref(SellCond,-1);
SellPrice=Open;
Short=0;Cover=0;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Thanks a lot, folks.

Al V.