@Paul
Do you use ATR for tralingstop on your 1s/10 strategy ? multiply by a ratio ?
maybe trailingstart and trailingstep would be eligible as parameters of the heuristic method..
PaulParticipant
Master
Do you use ATR for tralingstop on your 1s/10 strategy ?
Yes, tried the one you used too. Probably this one I like the most. Value 2 is nice for 1/10s with max 3. So this parameter doesn’t need to be optimised.
// trailing stop atr
once trailingstoptype = 1 // trailing stop - 0 off, 1 on
once trailingstoplong = 2 // trailing stop atr relative distance
once trailingstopshort = 2 // trailing stop atr relative distance
once atrtrailingperiod = 14 // atr parameter value
once minstop = 10 // minimum trailing stop distance
//----------------------------------------------
atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000
tgl = round(atrtrail*trailingstoplong)
tgs = round(atrtrail*trailingstopshort)
if trailingstoptype = 1 then
//
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
maxprice = 0
minprice = close
newsl = 0
endif
//
if longonmarket then
maxprice = max(maxprice,close)
if maxprice-tradeprice(1)>=tgl*pointsize then
if maxprice-tradeprice(1)>=minstop then
newsl = maxprice-tgl*pointsize
else
newsl = maxprice - minstop*pointsize
endif
endif
endif
if shortonmarket then
minprice = min(minprice,close)
if tradeprice(1)-minprice>=tgs*pointsize then
if tradeprice(1)-minprice>=minstop then
newsl = minprice+tgs*pointsize
else
newsl = minprice + minstop*pointsize
endif
endif
endif
//
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
if newsl>0 then
if low < newsl then
sell at market
endif
endif
endif
//
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
if newsl>0 then
if high > newsl then
exitshort at market
endif
endif
endif
endif
PaulParticipant
Master
the analysis of a candle of a higher timeframe is the way for the exit
Maybe if a position runs bad. For a trade in profit probably the trailingstop would be good enough.
But it could also be used to prevent taking a trade. At the moment I’am testing that with the doji.
I don’t like to have too many indicators. One for the trend has to be enough.
PaulParticipant
Master
I applied the re-enter code in same direction to the strategy.
If in a position and waiting for the trailingstop to be hit or the stoploss (or reversal signal), signals to enter in the same direction can appear which are ignored.
It’s interesting to see when they come and if the location is good or bad.
Maybe the most robust parameters are with this enabled when doing optimisation and then turn off going live.
once reenter=1
// entry
if ctime then
If (tradetype=1 or tradetype=2) then
if condbuy and not longonmarket then
buy positionsize contract at market
tradecounter=tradecounter+1
tradecounterlong=tradecounterlong+1
endif
endif
//
if (tradetype=1 or tradetype=3) then
if condsell and not shortonmarket then
sellshort positionsize contract at market
tradecounter=tradecounter+1
tradecountershort=tradecountershort+1
endif
endif
//
if reenter then
If (tradetype=1 or tradetype=2) then
if condbuy and longonmarket then
sell at market
endif
endif
If (tradetype=1 or tradetype=2) then
if condbuy[1] and not longonmarket then
buy positionsize contract at market
tradecounter=tradecounter+1
tradecounterlong=tradecounterlong+1
endif
endif
//
if (tradetype=1 or tradetype=3) then
if condsell and shortonmarket then
exitshort at market
endif
endif
if (tradetype=1 or tradetype=3) then
if condsell[1] and not shortonmarket then
sellshort positionsize contract at market
tradecounter=tradecounter+1
tradecountershort=tradecountershort+1
endif
endif
endif
endif
Hi,
this is an interesting project and I like the idea of candle patterns with few indicators.
I’ve had this idea of using Larry Williams “Smash Day Pattern”-strategy on lower Time Frames.
I think his idea is simply clever and may be useful.
I’ve started a little project on my own, for educational purpose, with code name “SmashBar, the Larry style”…yeah I know, the name is…ehum…silly 🙂
If it’s OK, I’ll put the code here (if I break any forum rules please remove the code). As I mentioned, I’m still learning so my code might be a bit clumsy and probably not at all coded as the “Smash Day Pattern”. But hey, learning by doing, right? 😉
I’ve got the idea from https://oxfordstrat.com/?s=smash and also found a topic here at prorealcode:
https://www.prorealcode.com/prorealtime-indicators/larry-williams-smash-days/
//SmashBar, the Larry style
defparam cumulateorders = false
defparam preloadbars = 5000
once positionsize = 1
once tradetype = 2 // [1]long&short;[2]long;[3]short
//========= STRATEGY ===================================
//long
c10=low<lowest[2](low[1])
c11=close<low[1]
tradelong = c10 and c11
//short
c20=high>highest[2](high[1])
c21=close>high[1]
tradeshort = c20 and c21
//=======================================================
// entry
If (tradetype=1 or tradetype=2) and tradelong then
if not onmarket then
buy positionsize contract at market
endif
endif
if (tradetype=1 or tradetype=3) and tradeshort then
if not onmarket then
sellshort positionsize contract at market
endif
endif
//%trailing stop function
trailingPercent = .26 //org .26
stepPercent = .015 //org .014
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailinstart points profit
trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stop
endif
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
newSL = tradeprice(1)+trailingstep
ENDIF
//next moves
IF newSL>0 AND close-newSL>trailingstep THEN
newSL = newSL+trailingstep
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
newSL = tradeprice(1)-trailingstep
ENDIF
//next moves
IF newSL>0 AND newSL-close>trailingstep THEN
newSL = newSL-trailingstep
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
thx for your feedback and sharing
you use at least atr indicator… 😉
on my side, i’m trying to run a reversal short after if it goes wrong
for the moment, i coded long and reversal short
i will check with an atr trailing stop if it’s better or not
i tried the system with doji, i don’t have good results for the moment..
i will code also the volatility scalper indicator inside this strategy (candle according to the big value of the ATR)
thx Keewee for sharing.. i will look
REversal trend if tp is not reached.
@MAKSIDE congrats for your great job… little question, what’s the position size in yout backtests?
And again, did you tried to work on larger timeframes like 10s?
@Francesco
Thx
About 10s, not yet. But why not. I prefer 1s for the moment. Maybe under 1s, one day… We hope…
About the position size, it’s a dynamic positionsize according to the strategyprofit and the type of strategy
Currently btw 1 to 8 positionsize following the case. Dji 2$, spread 2.
I will post the different profit with and without and with différent spread btw 2 to 6.
the simplest is the most complicated.. i foresee an enormous work..
some ideas about candlestick strategies
- Identify all existing candlestick pattern and new patterns from existing strategies, code or recode them
- Give them a weighting on each bullish and bearish candlestick pattern according to historic statistics based on each market, each time slot
- Include an IA in order to reoptimize the decision tree and the weighted value according to the strategyprofit
- Optimize the money management or other parameters according to the new weighted value reoptimized previously
please find a document regarding the mathematic popularization of HFT … lot of interesting things (sorry, in french)
https://samm.univ-paris1.fr/IMG/pdf/High_Frequency_Trading_Modeling_and_Statistical_Arbitrage.pdf
So are you implementing MM in your tests?
BTW, i can suggest you the three black crows and three withe soldiers patterns if you didn’t knew it. I think it would be pretty easy to implement if you think it’s worth.
That could help the “searching all existing patterns”
no Francesco, only candle and ATR
yes, i know, three soldiers and black crow, sure it’s easy. thx for sharing