Hi I’m new and not very experienced and for some time I try to learn information from the community. I ask you advice to improve this simple code that I developed but I would like to reduce the% Ma DrawDown and I think there is some error. Thanks to anyone who wants to help me.
//Eur/Usd mini - 1D Capital Eur 500,00
DEFPARAM CUMULATEORDERS= false
DEFPARAM PRELOADBARS = 10000
n=1
Atr = AverageTrueRange[14](close)
Atrs = 0.1
x = average[A,3]((High+Low+close)/3)
b1e = ((2*x)-high)+(ATR*ATRs)
s1e = ((2*x)-Low)-(ATR*ATRs)
Hbop = (2*x)-(2*Low)+High
Lbop = (2*x)-(2*High)+Low
// Condizioni per entrare su posizioni long
IF NOT LongOnMarket AND close<lbop THEN
BUY n CONTRACTS AT b1e limit
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket THEN
SELL AT s1e limit
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket AND close>hbop THEN
SELLSHORT n CONTRACTS AT s1e limit
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket THEN
EXITSHORT AT b1e limit
ENDIF
set stop loss (1.8*ATR)
Variable A is missing, what’s its value?
Are you aware that if your long or short limit orders open positions then you will not have a sell or exitshort order on the market until the close of the bar? You should add them in like this:
/ Condizioni per entrare su posizioni long
IF NOT LongOnMarket AND close<lbop THEN
BUY n CONTRACTS AT b1e limit
SELL AT s1e limit
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket THEN
SELL AT s1e limit
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket AND close>hbop THEN
SELLSHORT n CONTRACTS AT s1e limit
EXITSHORT AT b1e limit
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket THEN
EXITSHORT AT b1e limit
ENDIF
Variable A is missing, what’s its value?
a = 2
Tanks
DEFPARAM CUMULATEORDERS= false
DEFPARAM PRELOADBARS = 10000
capital = 500 + strategyprofit
n=1
Atr = AverageTrueRange[14](close)
Atrs = 0.1
x = average[2,3]((High+Low+close)/3)
ema=average[3,6](close)
b1e = ((2*x)-high)+(ATR*ATRs)
s1e = ((2*x)-Low)-(ATR*ATRs)
Hbop = (2*x)-(2*Low)+High
Lbop = (2*x)-(2*High)+Low
// Condizioni per entrare su posizioni long
IF NOT LongOnMarket AND close<lbop and close>ema THEN
BUY n CONTRACTS AT b1e limit
SELL AT s1e limit
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket THEN
SELL AT s1e limit
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket AND close>hbop and close<ema THEN
SELLSHORT n CONTRACTS AT s1e limit
EXITSHORT AT b1e limit
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket THEN
EXITSHORT AT b1e limit
ENDIF
set stop loss (1.8*ATR)
If Capital<-300 then
quit
endif
I’ve applied some variations like an EMA filter
You have to try changing values until you find the ones that you think are what suit you (not the market!) best.
Setting an average type of 2 (wma), instead of 3, then 1.3 at line 34, provided variable A has been assigned 2, my drawdown drops to 267.30 as from screenshot.
Try to walk forward your strategy.
I prefer to take stuff away rather than add it. I have removed the fixed level stop loss (it doesn’t add much anyway) and you have levels set to reverse the trades anyway. Most trades don’t seem to be more than one day so I have added exits at the close of any day that you are in profit. The ATRS variable has been optimised to 0.16. It seems pretty stable for a EUR/USD strategy. I wouldn’t add EMA’s as you are just adding an extra level of curve fit and EMA’s are oh so easy to curve fit!
//Eur/Usd mini - 1D Capital Eur 500,00
DEFPARAM CUMULATEORDERS= false
DEFPARAM PRELOADBARS = 10000
a = 2
t = 2
//m = 2.7
n=1
Atr = AverageTrueRange[14](close)
Atrs = 0.16
x = average[A,3]((High+Low+close)/3)
b1e = ((t*x)-high)+(ATR*ATRs)
s1e = ((t*x)-Low)-(ATR*ATRs)
Hbop = (t*x)-(t*Low)+High
Lbop = (t*x)-(t*High)+Low
// Condizioni per entrare su posizioni long
IF NOT LongOnMarket AND close<lbop THEN
BUY n CONTRACTS AT b1e limit
SELL AT s1e limit
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket THEN
SELL AT s1e limit
if close > positionprice then
sell at market
endif
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket AND close>hbop THEN
SELLSHORT n CONTRACTS AT s1e limit
EXITSHORT AT b1e limit
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket THEN
EXITSHORT AT b1e limit
if close < positionprice then
exitshort at market
endif
ENDIF
//set stop loss (m*ATR)
[attachment file=87383]
[attachment file=87384]
The name is Vonasi not Vanosi!
m is the multiple of the ATR for the stoploss. If you unremark the stoploss and unremark the m = 2.7 then you can run it with a stoploss. 2.7 was the value that gave highest results.
Just out of interest I decided to take my version of your strategy and convert it to an end of day strategy. So I removed the limit orders and just bought or sold if it was above or below lbop and hbop. I reinstated the stop loss and optimised it and ATRS. I tested back to the beginning of 1995. Even if the ride was a little rough especially through the 2008 recession it was still ultimately a good equity curve. You may be on to something with your ATR band calculations. Are you sure that you’re new to this game?
[attachment file=87402]
[attachment file=87403]
//Eur/Usd mini - 1D Capital Eur 500,00
DEFPARAM CUMULATEORDERS = false
DEFPARAM PRELOADBARS = 10000
a = 2
t = 2
m = 1.8
n=1
Atr = AverageTrueRange[14](close)
Atrs = 0.01
x = average[A,3]((High+Low+close)/3)
b1e = ((t*x)-high)+(ATR*ATRs)
s1e = ((t*x)-Low)-(ATR*ATRs)
Hbop = (t*x)-(t*Low)+High
Lbop = (t*x)-(t*High)+Low
// Condizioni per entrare su posizioni long
IF NOT LongOnMarket AND close <= lbop THEN
BUY n CONTRACTS AT market//b1e limit
//SELL AT s1e limit
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket and close > s1e THEN
SELL AT market//s1e limit
if close > positionprice then//positionprice then
sell at market
endif
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket AND close >= hbop THEN
SELLSHORT n CONTRACTS AT market//s1e limit
//EXITSHORT AT b1e limit
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket and close < b1e THEN
EXITSHORT AT market//b1e limit
if close < positionprice then
exitshort at market
endif
ENDIF
set stop loss (m*ATR)
//graph b1e
//graph s1e
//graph Hbop
//graph Lbop
//
Ok ok sorry Vonasi 🙂 Have a nice weekend…..
What an early weekend! You’re lucky Vonasi.
Roberto, I forgot that someone need still to work … 😁😁