Hi,
I tried to make a strategy based on Volatility Scalper Indicator of Nicolas. As a reminder, this indicator detects the high volatility of market places. It’s the reflect when the market is making big move on the same bar.
This strategy is based on this indicator.
- When the value of the upside volume is considered as good, value > treshold and close > long MM, -> buy position is taken.
- When the value of the downside volume is considered as good, value > treshold and close < long MM, -> sell position is taken.
- Stop according to traling stop
- time 1530 – 2200, everyday
- option / reversal position size (possibility to activate or not)
- option for buy, sell or both
all suggestions are open…
- maybe specify more precise time ranges according to the volatility of DJI, same thing for different days… ?
- others ?
- …
- others.. ?
//VOLATILITY SCALPER STRATEGY
//@MAKSIDE - 2020
//V0.1
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Volatility Scalper
//@Nicolas/PRT
// Variables
threshATRPeriod = 40
smoothing = 2
verticalShiftPercent = 0
// --
threshATRPeriod = max(1, threshATRPeriod)
smoothing = max(1, smoothing)
diff = averagetruerange[1] - averagetruerange[2]
if(close-close[1])>0 THEN
upsidevol = averagetruerange[1] + diff * 0.5
upsideVol = max(upsideVol, 0)
downsidevol = 0
ELSE
upsidevol = 0
downsidevol = averagetruerange[1] + diff * 0.5
downsideVol = max(downsideVol, 0)
ENDIF
t = DEMA[smoothing](AverageTrueRange[threshATRPeriod])
t = t + (t*(verticalShiftPercent/100))
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//PARAMETERS OF STRATEGY **************************************
//level of volatility indicator / bull market
Cupsidevol = 10
//level of volatility indicator / bear market
CdownsideVol = 20
//buy conditions
Cdatetimebuy = (CurrentTime > 153000) and currenttime < 220000
//sell conditions
Cdatetimesell = (CurrentTime > 153000) and currenttime < 220000
Cbuy = upsidevol>Cupsidevol and upsidevol > t and Cdatetimebuy
Csell = downsidevol>CdownsideVol and downsidevol > t and Cdatetimesell
// Strategy - 1 : buy, 2 : sell, 3 : both
Cchoice = 2
//Reverse martingale 1 : ON, 0 : OFF
levier = 1
n = 1
reversemartingale = 0
//$$$$$$$$$$$$$$ REVERSE MARTINGALE
// in case of loss, back to initial value 1
// in case of winning, increase by one unit
// in case of 4 consecutive wins, back to initial value 1
if reversemartingale = 1 then
ONCE n = levier
IF Strategyprofit<Strategyprofit[1] THEN
n = levier
ENDIF
IF Strategyprofit>Strategyprofit[1] THEN
n = n + levier
ENDIF
IF n >= 6 * levier THEN // modifier la valeur selon vos préférences
n = levier
ENDIF
endif
//STRATEGY **************************************
//
if Cchoice = 1 or 3 then
if close > Average[4800](close) then
IF not longonmarket and Cbuy THEN
BUY n CONTRACT AT MARKET
ENDIF
SET STOP pLOSS 5
endif
endif
if Cchoice = 2 or 3 then
if close < Average[4800](close) then
IF not shortonmarket and Csell THEN
sellshort n CONTRACT AT MARKET
ENDIF
SET STOP pLOSS 5
endif
endif
//TRAILING STOP **************************************
trailingstart = 15 //trailing will start @trailinstart points profit
trailingstep = 5 //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
//************************************************************************
For the moment, that doesn’t work with proorder..
I have that systematically..
Hi and thank you for your code!
Really like the stratergy. I was trying to put it live on my demo but gets an error just after I start it? Have checked the code and the only thing I changed was the ploss to 6 because that’s the min stopploss? But also tried with higher without succes.
Are you sure about the ploss set to 6 with IG account/DJI ?
please note, the gain is more important.. 862$ for my sample.. it’s 1.6 for the spread between 1530 – 2200 with IG.
In my example, i took 2 for the spread.
But you are right… i modified and try with different values for ploss and that the same thing.. bot rejected immediately
When you try to start the bot this comes up (see picture)
I got no near your gain with 1 contract with 100k units. (see picture of my backtest)
For the spread normally its 1,6 but nowdays its going up and down like crazy.
@MrCool
It’s not DJI 1€ .. but DJI 2$ used.
814$ with reversemartingale = 0
838$ with reversemartingale = 1
when this bot will work, be careful, please check this value because it’s not the value 1 which will be given to proorder but more if reversemartingale is on… (position size is increased in this case)
Ah my bad! Now I get the same results and it’s doing good today 🙂
Yes I’m aware of that, thank you!
Do you think its wrong with the code or ptr?
I don’t know.. I open a ticket through held desk center of PRT
i’m waiting and sure, i will come back soon 😉
Try to add a a defparam preloadbards = 1000 at the top of the code.
You should also calculate your position size only before entering a new order, because now the “n” variable is calculating on each bar, even if you don’t meet the requirement to open a new position at market. So move the martingale code before line 79 and 91.
@Nicolas
you are right, but i just tested. as soon as i start prorder, the strategy is rejected…
Sorry, I forgot a zero:
defparam preloadbars = 10000
Good morning,
The minimum stop this morning is 1095 point see attached picture