PaulParticipant
Master
Hi, I’am stuck on something. It’s not intended for live, but for backtest purpose.
defparam cumulative orders=true.
I’ve a buy signal and a long position will be sold at the market next bar open.
But at the same time I need to buy at that bar where that long position was closed.
How do I write the condition with stop/limit so the order will always be executed, regardless how the next candle (after the signal) looks or gaps.
So far I’ve this and works in part. In pic an example where it doesn’t work.
if longonmarket and condbuy and (reentry=1 or reentry=2) then
sell positionsize contract at market
newprice=close
if newprice=newprice+0.01 then
buy positionsize contract at newprice stop
else
buy positionsize contract at newprice limit
endif
set stop %loss sll
set target %profit ptl
endif
You can’t, unless you use the MTF support with a default 1-minute TF and BUY 1 minute after the previous position is closed.
This is because ProOrder needs one bar before knowing the updated OnMarket status.
PaulParticipant
Master
Thnx roberto. that’s a shame. I don’t want to use MTF because that defeats the purpose.
But I’ve changed it a little. Removed the 0.01, the condition is always true.
It works often now. I will update progress on the concept in the vectorial dax topic.
PaulParticipant
Master
Here’s the file i’ve been working on.
step1 & step2 use with cumulative orders set to true, optimising one or both steps to find good values to be used in step3.
step3 set cumulative orders to false for live trading
this is about seeing the trades that the normal backtest might not see because it is already on the market. Now those trades/signals have more meaning when optimising and always have impact. Best is to have all 3 equity-curves look similar (regardless the extra spread/trades with step1/2)
Maybe it will be useful and can be improved or maybe it’s not useful at all. I’am not sure yet.
example; dow 5m 100k optimised with a dpo setup for long
PaulParticipant
Master
@nonetheless
After having founded good & robust entry settings, added Roberto’s ts (disabled pt) and you have on (step3) a nice equity-curve on 200k. Maybe I shouldn’t have posted it here in this topic. But pretty good for an entry parameter with only 1 (best) value which is 100! Should be robust on vrt too I hope.
This is a really cool idea – comes close to incorporating VRT at the optimization level by using more of the possible entries. I’ll have to make some time to play around with it, thanks for sharing!