With your extra entry conditions you basically filter out half of the existing trades… I’m not sure if that’s over-optimization. Set highest and lowest to 1…. so we trade almost every day. And then show your capital curve.
JSParticipant
Senior
Hi @fifi743
Your back test was done with a $250/point contract…
In my system there are two contracts with a value of 250 dollars/point, SPTRD (US 500 Cash) and SPTRD (US 500 Cash (250$))…
I don’t see any difference between these two contracts, only when I back test them I get the same result with the US 500 Cash as your back test, only when I use the other contract, I get the back test below… (Both 200k units)
My version is based on the SP500 with €1 per point…
Here is the curve with SP 500 1 dollar per point
positionsize=1
JSParticipant
Senior
Fifi, your last back test is also based on a contract with 250$/point… 🙂
hi phoentzs, I was just reading your code/script and was immediately excited about basic simplicity of the trading idea/concept. I “feel”/guess it is a valid, probably very competetive concept. (well, I would not say it has to do something with gap-trading). and you make it totally without common indicators-shmindincators – fascinating! 😀
few ideas/remarks, after looking in the details and “action” of the algo:
- by implementing mylowX and myhighX with variables “inside” (number of days you look back), you created kind of your own indicator with huge potential for optimization. why not to look just to previous day’s high & low as a trigger? simple, logical, no chance for optimization (and results are still very okay, I would say).
- something is “fishy” with mondays’ trades. one idea as a consequence is not to take any trades on mondays at all. but I think monday’s real issue in the algo is the open/close/high/low data which PRT/workstation provides you on “monday” on the “daily” timeframe, and correspondingly it influences all your own parameters which you link to this data, possibly to you disadvantage. please observe closely on the chart what your parameters (all which you are calling “my….” and “area” which is linked to “my…”) are doing on sunday/early monday.
regards
justinas
…sorry, maybe i expressed myself in misleading way: by „huge potential for optimization“ I mean that it is probably to your/trader‘s disadvantage! any variable which can be „optimized“ a lot decreases probably the robustness and so the chance that system makes money in various market conditions in the future. in your particular system I dont see any strong/logical/economical etc reason to make number of days you look back a „variable“. 1 day is supe fine, sigificant, simple, logical… another period could be 1 full working week. something in between or so might/will work as well but possibly is kind of „magic“, you might not want to rely on, even if it „produces“ more smooth equity curve or lower absolute drawdown or whatever more nice performance in the backtest/on paper.
@justisan
Thanks for your praise. Well, mylowx and myhighx also work great if you only use the previous day of both. I tried to get a certain long/short weighting into the system by optimizing both values. It is difficult to say whether the values are now over-optimized. In any case, many combinations work without the system breaking down. Which basically suggests that it is quite robust. The Monday problem… yes, the problem is that PRT also produces Sunday candles every now and then. So when we go to the store on Monday, we sometimes take the Sunday candle, which of course is nonsense. But unfortunately I haven’t figured out how to filter out this candle yet? Normally we should access the Friday candle on Mondays, which sometimes doesn’t work. As a result, we occasionally have poor performance on Mondays. Maybe someone has an idea how to basically filter out the Sunday candle?
Hi Phoentzs, what do you think about the idea of separating Monday from the other days and let him take the value of the previous day (to check)?
defParam cumulateOrders = false
defParam preLoadBars = 10000
defParam flatAfter = 220000
cTime = time >= 080000 and time <= 210000
positionSize = 4
//-----------------------------------------------------------------------
once maxOrdersL = 1 //max-Orders per Day
once maxOrdersS = 1
if intradayBarIndex = 0 then //reset orders count
ordersCountL = 0
ordersCountS = 0
endif
if longTriggered then //check if an order has opened in the current bar
ordersCountL = ordersCountL + 1
endif
if shortTriggered then //check if an order has opened in the current bar
ordersCountS = ordersCountS + 1
endif
//------------------------------------------------------------
timeframe(1 day, updateOnClose)
//*********************************
periodL = 3
periodS = 13
multiplierL = 0.4
multiplierS = 1
//*********************************
monday = dayOfweek = 1
dailyHighMonday = high[1]
dailyCloseMonday = close[1]
dailyLowMonday = low[1]
dailyOpenMonday = open[1]
areaDailyMonday = dailyHighMonday - dailyLowMonday
dailyLowXMonday = lowest[periodL+1](low)
dailyHighXMonday = highest[periodS+1](high)
dailyHigh = high
dailyClose = close
dailyLow = low
dailyOpen = open
areaDaily = dailyHigh - dailyLow
dailyLowX = lowest[periodL](low)
dailyHighX = highest[periodS](high)
//--------------------------------------------------------------
timeframe(15 minutes)
//---------------------------------------------------------------
cLongMonday = close < dailyLowXMonday
cShortMonday = close crosses under dailyHighXMonday
cLong = close < dailyLowX
cShort = close crosses under dailyHighX
//------------------------------------------------------------------
if monday then
if cTime and cLongMonday and ordersCountL < maxOrdersL then
buy positionSize contracts at market
set stop loss areaDailyMonday * multiplierL
endif
if longOnMarket and close > dailyCloseMonday and positionPerf*100 > 0.1 then // exit: gain > 0.1%
sell at market
endif
if cTime and cShortMonday and ordersCountS < maxOrdersS then
sellshort positionSize contracts at market
set stop loss areaDailyMonday * multiplierS
endif
if shortOnMarket and close < dailyCloseMonday and positionPerf*100 > 0.3 then // exit: gain > 0.3%
exitShort at market
endif
endif
//****************************************
if not monday then
if cTime and cLong and ordersCountL < maxOrdersL then
buy positionSize contracts at market
set stop loss areaDaily * multiplierL
endif
if longOnMarket and close > dailyClose and positionPerf*100 > 0.1 then // exit: gain > 0.1%
sell at market
endif
if cTime and cShort and ordersCountS < maxOrdersS then
sellshort positionSize contracts at market
set stop loss areaDaily * multiplierS
endif
if shortOnMarket and close < dailyClose and positionPerf*100 > 0.3 then // exit: gain > 0.3%
exitShort at market
endif
endif
//---------------------------------------------------------------------------------------
graphOnPrice dailyLowX coloured("red")
graphonprice dailyClose coloured("black")
graphOnPrice dailyHighX coloured("green")
@mauropro
That sounds good too. Can you post me the curve?
The version with the distinction of Monday (the one above) is the version 3 (I think that the parameters of Monday should be optimizied).
One could implement this change. The idea is good. Even if the impact on overall performance is minimal.
This is the version 3 with
only Monday optimized ( the impact is not so small: more than 10%).
//SP "lowBuy-highSell" v3 15m [spread 0.6] //TS by Phoentzs
//https://www.prorealcode.com/topic/m15-sp500-lowbuyhighsell-strategy/
//*********************************************************************************
defParam cumulateOrders = false
defParam preLoadBars = 10000
defParam flatAfter = 220000
cTime = time >= 080000 and time <= 210000
positionSize = 4
//-----------------------------------------------------------------------
once maxOrdersL = 1 //max-Orders per Day
once maxOrdersS = 1
if intradayBarIndex = 0 then //reset orders count
ordersCountL = 0
ordersCountS = 0
endif
if longTriggered then //check if an order has opened in the current bar
ordersCountL = ordersCountL + 1
endif
if shortTriggered then //check if an order has opened in the current bar
ordersCountS = ordersCountS + 1
endif
//------------------------------------------------------------
timeframe(1 day, updateOnClose)
//*********************************
periodL = 3
periodS = 13
multiplierLMonday = 0.3 // monday OPT
multiplierSMonday = 0.5 // monday OPT
exitLMonday = 0.2 // monday OPT
exitSMonday = 0.4 // monday OPT
multiplierL = 0.4
multiplierS = 1
exitL = 0.1
exitS = 0.3
//*********************************
monday = dayOfweek = 1
dailyHighMonday = high[1]
dailyCloseMonday = close[1]
dailyLowMonday = low[1]
dailyOpenMonday = open[1]
areaDailyMonday = dailyHighMonday - dailyLowMonday
dailyLowXMonday = lowest[periodL+1](low)
dailyHighXMonday = highest[periodS+1](high)
dailyHigh = high
dailyClose = close
dailyLow = low
dailyOpen = open
areaDaily = dailyHigh - dailyLow
dailyLowX = lowest[periodL](low)
dailyHighX = highest[periodS](high)
//--------------------------------------------------------------
timeframe(15 minutes)
//---------------------------------------------------------------
cLongMonday = close < dailyLowXMonday
cShortMonday = close crosses under dailyHighXMonday
cLong = close < dailyLowX
cShort = close crosses under dailyHighX
//------------------------------------------------------------------
if monday then
if cTime and cLongMonday and ordersCountL < maxOrdersL then
buy positionSize contracts at market
set stop loss areaDailyMonday * multiplierLMonday
endif
if longOnMarket and close > dailyCloseMonday and positionPerf*100 > exitLMonday then
sell at market
endif
if cTime and cShortMonday and ordersCountS < maxOrdersS then
sellshort positionSize contracts at market
set stop loss areaDailyMonday * multiplierSMonday
endif
if shortOnMarket and close < dailyCloseMonday and positionPerf*100 > exitSMonday then
exitShort at market
endif
endif
//****************************************
if not monday then
if cTime and cLong and ordersCountL < maxOrdersL then
buy positionSize contracts at market
set stop loss areaDaily * multiplierL
endif
if longOnMarket and close > dailyClose and positionPerf*100 > exitL then
sell at market
endif
if cTime and cShort and ordersCountS < maxOrdersS then
sellshort positionSize contracts at market
set stop loss areaDaily * multiplierS
endif
if shortOnMarket and close < dailyClose and positionPerf*100 > exitS then
exitShort at market
endif
endif
//---------------------------------------------------------------------------------------
graphOnPrice dailyLowX coloured("red")
graphonprice dailyClose coloured("black")
graphOnPrice dailyHighX coloured("green")
//---------------------------------------------------------------------------------------------
Now it gets interesting. Thanks. I’ll run the versions in parallel in a demo to see if everything runs robustly. As mentioned at the beginning, this system would be ideal for a portfolio to hedge trend strategies. At least that’s my idea.