Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)

if we stop thinking about buying at a specific time but rather at a specific value then we have solution to this. If you want to buy as soon as the price is greater than a variable X That means you want your entry price to be a tiny bit above X. ( Of course that would only work in real time and if your broker applies these buy and sell conditions for you ... blah blah :) ) Now I don't think this could done in a system tester, but it can be done in an exploration, a bit like the PS performance explorations...
Using your formula and creating a copy of a points only system test (Using close and zero delay) we would have the following for an exploration :
( I'm assuming here that your exit signal is the opposite of the entry signal formula )
ColumnA Name :Long Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); Cum(If(State=1,ROC(C,1,$),0))
ColumnB Name : Short Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); Cum(If(State=1,Neg(ROC(C,1,$)),0))
ColumnC Name : Long/Short Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); Cum(If(State=1,Roc(C,1,$),If(State=1,Neg(ROC(C,1,$)),0)))
Now let's modify this so that it calculates profit as soon as our condition is met. Which here really means "let's add a specific entry price to the formula". Earlier I said you want your entry price to be a tiny bit above X X = Ref(HHV(H,20),1) or X = Ref(LLV(L,20),1) + tinybit= 0.01 or tinybit= 0.01 :)
Here is the final exploration
ColumnA Name :Long Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); LEntryPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; LExitPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SEntryPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SExitPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; Cum(If(Cross(0,State),LExitPriceLentryPrice,0))
ColumnB Name : Short Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); LEntryPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; LExitPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SEntryPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SExitPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; Cum(If(Cross(State,0),SEntryPriceSExitPrice,0))
ColumnC Name : Long/Short Profit Formula :
BC:=Cross(H,Ref(HHV(H,20),1)) ; SC:=Cross(Ref(LLV(L,20),1),L); State:=If(BC,1,If(SC,1,PREV)); LEntryPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; LExitPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SEntryPRICE:=ValueWhen(1,Cross(0,State),Ref(LLV(L,20),1))0.01; SExitPRICE:=ValueWhen(1,Cross(State,0),Ref(HHV(H,20),1))+0.01; Cum(If(Cross(0,State),LExitPriceLentryPrice,If(Cross(State,0),SEntryPriceSExitPrice,0))
A few note about this, the columns name are too long I know ... I have not tested this ... And these formula will unfortunately not include the first 2 trades on each side.
Do I need to put a disclaimer here saying that this is not a recommendation to buy sell ... :D
