You are on page 1of 1

{Break evet} EnterCondition:= Mov(C,13,S) > Mov(C,26,S) AND C > Mov(C,13,S) AND C > 0.

2 AND Mov(V,10,S) > 1000000; Event := H > HHV(Ref(H,-1),10) AND EnterCondition; {Correction period} Enter := BarsSince(EVENT)>=1 AND BarsSince(EVENT)<10; {Break Bar High} BBH := ValueWhen(1,EVENT,H); {Lower than Break Bar Low} Correction := L < Ref(LowestSince(1,Event,L),-1); {Counter} Count := Cum(Correction); Counter := Count - ValueWhen(1,Event,Count); {Entry Price} EntryPrice:= If(Counter<2,BBH,Max(ValueWhen(1,Correction,H),ValueWhen(2,Correction,H)))+0.005; StopLoss := LowestSince(1,Event,L); {Each position is limited to $20k, it's rounded down to nearest 1000 unit} {Size := PREC(Min(20000/Entry,500/(Entry-StopLoss+0.01))/1000,0)*1000;} Size := 500/(EntryPrice-StopLoss+0.01); {TwoBar := LowestSince(2,H>HHV(Ref(H,-1),10),L);} {ExitPrice := Max(StopLoss,TwoBar);} EntryAction := H>Ref(EntryPrice,-1) AND Ref(Enter,-1); {EnterCounter} EntryActionCount := Cum(EntryAction); EntryCounter := EntryActionCount - ValueWhen(1,L<ValueWhen(2,EntryAction,Ref(StopLoss,1)),EntryActionCount); ModEntryAction := EntryAction AND EntryCounter=1; ModEntryPrice := ValueWhen(1,ModEntryAction,EntryPrice); EntryPriceLatch := ValueWhen(1,ModEntryAction,EntryPrice); StopLossLatch := ValueWhen(1,ModEntryAction,Ref(StopLoss,-1))-0.005; ExitPrice :=EntryPriceLatch + 2*(EntryPriceLatch-StopLossLatch+0.01)+0.005; ExitPriceLatch := ValueWhen(1,ModEntryAction,ExitPrice); ExitAction := L<StopLossLatch OR H>ExitPriceLatch; ExitPrice := If(L>EntryPriceLatch, ExitPriceLatch, StopLossLatch);