I made an MTF version for DAX €1, 5 minutes and added Nicolas’trailing stop code, trading hours, target profit and removed FlatBefore and FlatAfter:
// _ZiBoll DAX mtf
//
// https://www.prorealcode.com/topic/ziboll-indicator/#post-120704
//
defparam CumulateOrders = false
TIMEFRAME(4 hour,updateonclose) //4h
TradingTime = OpenTime >= 090000 AND OpenTime <= 210000 //09:00 - 21:00
p = 11 //11
s = 0.3 //0.3
// Computes the basic moving average from the low and from the high
BollMALow = WeightedAverage[p](Low)
BollMAHigh= Weightedaverage[p](High)
// Computes the Standard Deviation (You can also take fx for colculate the "StdSTD[20](close)")
//Compute the Special Bollinger Bands.
//Instead of two times the STDDEV we calculate 0.5 times the STDDEV , and subtract it from the LowMA
//For the upper value we take 0.5 times the STDDEV and add it to the HighMA
BupH = BollMaHigh + (s * STD[p](high)) //Boll+
BdnL = BollMALow - (s * STD[p](low))//Boll-
//Compare the results with the close of each candle
//Lower than the close its -1
//Higher than the close its +1
//Between the two values equals the previous values
if close < BdnL then
ZHL=-1
elsif close> Buph then
ZHL=1
else
ZHL=ZHL[1]
endif
//First check the trend by means of the regressionslope
zbsl=sin(LinearRegressionSlope[p](bdnl)+LinearRegressionSlope[p](buph))/2
//The Boolean value of ZHL
if zbsl > 0 then
if ZHL crosses over 0and TradingTime then
buy 1 contract at market
endif
elsif zbsl < 0 then
if zhl crosses under 0 and TradingTime then
sellshort 1 contract at market
endif
endif
if longonmarket then
if zhl crosses under 0 then
sell at market
endif
elsif shortonmarket then
if zhl > 0 then
exitshort at market
endif
endif
// Stops en targets
set target pprofit 60 //60
set stop ploss 23 //23
//
TIMEFRAME(default) //5 min
//************************************************************************
//trailing stop function
trailingstart = 20 //20 trailing will start @trailinstart points profit
trailingstep = 26 //26 trailing step to move the "stoploss"
//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*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
I did a 5 min version also on the DJI, I thought I had posted results last night, but either I flicked to another screen before it got sent fully or the site was doing it’s security wiping of Logins?
All I did was optimise the 2 variables as below, so it may not be as predictable as Roberto DAX M5 version.
p= 6 //11
s= 1.7 //0.5