PaulParticipant
Master
Too bad! But perhaps there’s a better way then I coded.
Will post back soon. In the meantime, did you change the values nopl/nops 2 and 14 or made other modification?
PaulParticipant
Master
It’s a problem I experienced earlier, especially when you have the values nopl/nops both low.
Criteria for long and short can both be true and at the same bar.
I removed the workaround. Another permanent fix is using “crosses over/under”.
if tradetime then
if time = entertime then
dayopen=open
endif
donopl=dayopen+nopl
donops=dayopen-nops
if high > donopl and c10 then
mclong=1
else
mclong=0
endif
if low < donops and c10 then
mcshort=1
else
mcshort=0
endif
endif
// [ec] extra criteria
if extratradecriteria then
eclong = high < dhigh(1)
ecshort = low > dlow(1)
else
eclong=1
ecshort=1
endif
// long & short entry
if not onmarket and tradetime then
if pclong and mclong and eclong then
if ordertype=1 then
buy positionsize contract at market
longtradecounter=longtradecounter + 1
tradecounter=tradecounter+1
elsif ordertype=2 then
buy positionsize contract at donopl stop
longtradecounter=longtradecounter + 1
tradecounter=tradecounter+1
elsif ordertype=3 then
buy positionsize contract at donopl limit
longtradecounter=longtradecounter + 1
tradecounter=tradecounter+1
endif
endif
if pcshort and mcshort and ecshort then
if ordertype=1 then
sellshort positionsize contract at market
shorttradecounter=shorttradecounter + 1
tradecounter=tradecounter+1
elsif ordertype=2 then
sellshort positionsize contract at donops stop
shorttradecounter=shorttradecounter + 1
tradecounter=tradecounter+1
elsif ordertype=3 then
sellshort positionsize contract at donops limit
shorttradecounter=shorttradecounter + 1
tradecounter=tradecounter+1
endif
endif
endif
PaulParticipant
Master
This code uses trailing stop. I’am working on a bollingerband exits as alternative.
It’s coming on nicely. This is with a disabled trailing stop on the V2.
Nice; could you post it soon?
PaulParticipant
Master
sure, it’s about the same concept as in the other strategy.
normally I use 1% stoploss, but 0.5% worked too.
goodluck
bu=bollingerup[20](close)
bd=bollingerdown[20](close)
br=(bu-bd)
pp=(positionperf*100)
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
flag=0
endif
if pp>=0.35 and (open>bu or open<bd) then
flag=1
endif
if longonmarket and (flag=1) and high<bu and (br<br[1] and br[1]<br[2] and br[2]<br[3] and br[3]<br[4]) then
sell at market
endif
if shortonmarket and (flag=1) and low>bd and (br<br[1] and br[1]<br[2] and br[2]<br[3] and br[3]<br[4]) then
exitshort at market
endif
A bit lost in the codes, sorry?. Could you post the entire code with BB? A favorite one for you/compared on 200k? Thanks for your kindness 🙂
Hi Paul,
i was wondering if we could add this feature, with “fake orders” under the mean, and if it would be a good way to improve the strategy?
https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/
Im’ not strong enough to code it, with our strategy….Would you be able to test iit?
Another idea, maybe we could avoid losses when the gain is closed under its medium boll? And take news trades only when the opening of a new trade is opened above its medium boll, to follow the trend.
PaulParticipant
Master
@winnie37 Thnx for the link.
Here’s the difference with the code from above.
Bollinger exit v2 vs trailing stop exit v1.
I will review the code v2 and post it later. Both exits have their strengths.
Thanks Paul. What do you think about the idea around the mean of gains, with “fake order”? Very nice on the paper, but no idea if it could really improve our results…
@winnie37 Thnx for the link.
Here’s the difference with the code from above.
Bollinger exit v2 vs trailing stop exit v1.
I will review the code v2 and post it later. Both exits have their strengths.
I suppose it’s the lastest postion on this morning on the screen you posted. I took it with a large potential gain, which has been strongly reduced at the close. On your v2, it seems not to be the case. Surely, both have their strenghs, avantages and inconvenients…
PaulParticipant
Master
@winnie37
I tried your link & to insert the code in the strategy. Only focused on PT&SL
It created an infinite loop and didn’t work. At the moment I will leave it at that, perhaps I will ‘ve a look later on again.
The strategy is supposed to do only one trade a day.
About the closing tip, you could try to adjust the bb strategy. Hopefully you find an exit with better results.
PaulParticipant
Master
v3
a few changes;
- slightly changed the way it goes to market
- expanded holidays
- exit if position is hold overnight into a holiday
- add bollingerband exits
- add trend safety exit flexibility
note
- only bb, no ts, potential profit >=0.35 can turn into loss
- only ts, no bb, potential profit >=0.35 can turn to breakeven
safest is to combine both.
v3
a few changes;
- slightly changed the way it goes to market
- expanded holidays
- exit if position is hold overnight into a holiday
- add bollingerband exits
- add trend safety exit flexibility
note
- only bb, no ts, potential profit >=0.35 can turn into loss
- only ts, no bb, potential profit >=0.35 can turn to breakeven
safest is to combine both.
It sounds good! A compared test on 200K?