ProRealCode - Trading & Coding with ProRealTime™
Hello,
I present you a strategy based on ichimoku and some optimizations.
Ichimoku is optimized to give the best components while keeping the same ratios of difference between the components of the ichimoku.
The values are therefore simply multiplied.
Purchases and sales are processed independently, which makes the backtest more profitable.
Also a currency management system is incorporated into the strategy and can be modified as required.
I wouldn’t have 100% confidence in this strategy given that it has just been developed and we know the effects of optimization.
However, I find it an interesting basis, which could be applied in other markets.
Maybe some ideas could be added to this one to make it more profitable!
Feel free to give your opinions and suggestions.
IV
//
//=/===============/=//=/===============/=//=/ Basic settings
//
//=/ Cumulation of Orders
DefParam CumulateOrders = False
//
//=/===============/=//=/===============/=//=/ Management Settings
//
//=/ Capital
Capital = 10000
//=/ Percentage Risk
Risk = 1
//=/ Reinvestment
Reinvestment = 0
//
//=/===============/=//=/===============/=//=/ Calcul Management Settings
//
//=/ Reinvestment Settings
if Reinvestment = 1 then
Capital = Capital + StrategyProfit
elsif Reinvestment = 0 then
Capital = Capital
endif
//=/ Lotss Settings
Lotss = ((Capital*Risk) /100) /RiskVolatility
if Lotss < 0.5 then
Lotss = 0.5
endif
if Lotss > (0.0015*Capital) then
Lotss = 0.0015*Capital
endif
//=/ Risk by Volatility Settings
VL1 = Average[500,0](TypicalPrice)
VH1 = VL1 + (1*Average[500,1](Range))
VD1 = VL1 - (1*Average[500,1](Range))
VL2 = Average[1000,0](TypicalPrice)
VH2 = VL2 + (1*Average[1000,1](Range))
VD2 = VL2 - (1*Average[1000,1](Range))
VH = (VH1+VH2) /2
VD = (VD1+VD2) /2
RiskVolatility = VH-VD
//
//=/===============/=//=/===============/=//=/ Activation Settings
//
//=/ Buy Activation
BuyActivation = 1
//=/ Sell Activation
SellActivation = 1
//
//=/===============/=//=/===============/=//=/ Time Settings
//
//=/ TimeTable
Before = Time >= 080000
After = Time < 220000
TTime = Before and After
//=/ No Trade
if OpenDayOfWeek = 5 and Time > 200000 then
NoTrade = 1
else
NoTrade = 0
endif
//
//=/===============/=//=/===============/=//=/ Indicator Settings
//
//=/ Ichimoku Buy
ICBuy = 1.13
BSpanA = (BTenkan[26*ICBuy]+BKijun[26*ICBuy])/2
BTenkan = (highest[9*ICBuy](high)+lowest[9*ICBuy](low))/2
BKijun = (highest[26*ICBuy](high)+lowest[26*ICBuy](low))/2
BSpanB = (highest[52*ICBuy](high[26*ICBuy])+lowest[52*ICBuy](low[26*ICBuy]))/2
//=/ Ichimoku Sell
ICSell = 0.86
SSpanA = (STenkan[26*ICSell]+SKijun[26*ICSell])/2
STenkan = (highest[9*ICSell](high)+lowest[9*ICSell](low))/2
SKijun = (highest[26*ICSell](high)+lowest[26*ICSell](low))/2
SSpanB = (highest[52*ICSell](high[26*ICSell])+lowest[52*ICSell](low[26*ICSell]))/2
//
//=/===============/=//=/===============/=//=/ Buy Settings
//
//=/ Conditions Buy
CB1 = momentum[9] > 0
CB2 = momentum[44] > 0
CB3 = momentum[187] > 0
CB4 = close > BSpanA and close > BSpanB
CB5 = BKijun > BSpanA and BKijun > BSpanB
CB6 = close > BTenkan and close > BKijun
CB7 = BTenkan > BSpanA and BTenkan > BSpanB
CB8 = close > BSpanA[26*ICBuy] and close > BSpanB[26*ICBuy]
CB9 = close > BTenkan[26*ICBuy] and close > BKijun[26*ICBuy]
ConditionsBuy = CB1 and CB2 and CB3 and CB4 and CB5 and CB6 and CB7 and CB8 and CB9
//=/ Conditions Sell
CXB1 = close < open
CXB2 = close < BSpanA and close < BSpanB
CXB3 = BKijun < BSpanA and BKijun < BSpanB
CXB4 = close < BTenkan and close < BKijun
CXB5 = BTenkan < BSpanA and BTenkan < BSpanB
CXB6 = close < BSpanA[26*ICBuy] and close < BSpanB[26*ICBuy]
CXB7 = close < BTenkan[26*ICBuy] and close < BKijun[26*ICBuy]
ConditionsSell = CXB1 and CXB2 and CXB3 and CXB4 and CXB5 and CXB6 and CXB7
//=/ Confirmation Time Buy
if ConditionsBuy then
CB = 1
elsif ConditionsSell then
CB = -1
else
CB = 0
endif
CTB1 = CB[1] = 1
CTB2 = CB[2] = 1
CTB3 = CB[3] = 1
CTB4 = CB[4] = 1
CTB5 = CB[5] = 1
CTB6 = CB[6] = 1
CTB7 = (close-open) > (high-close)
CTB = CTB1 and CTB2 and CTB3 and CTB4 and CTB5 and CTB6 and CTB7
if CTB then
ConfirmationTimeBuy = 1
else
ConfirmationTimeBuy = 0
endif
//=/ Buy
if NoTrade = 0 and BuyActivation = 1 and TTime and ConditionsBuy and ConfirmationTimeBuy = 1 then
Buy Lotss Contract at Market
Set Stop %Loss 2.27
endif
//=/ Sell
if NoTrade = 1 or close < BKijun and close > PositionPrice or ConditionsSell then
Sell at Market
endif
//
//=/===============/=//=/===============/=//=/ Sell Settings
//
//=/ Conditions Sell Short
CS1 = close < open
CS2 = momentum[18] < 0
CS3 = momentum[167] < 0
CS4 = momentum[224] < 0
CS5 = close < SSpanA and close < SSpanB
CS6 = SKijun < SSpanA and SKijun < SSpanB
CS7 = close < STenkan and close < SKijun
CS8 = STenkan < SSpanA and STenkan < SSpanB
CS9 = close < SSpanA[26*ICSell] and close < SSpanB[26*ICSell]
CS10 = close < STenkan[26*ICSell] and close < SKijun[26*ICSell]
ConditionsSellShort = CS1 and CS2 and CS3 and CS4 and CS5 and CS6 and CS7 and CS8 and CS9 and CS10
CXS1 = close > open
CXS2 = close > SSpanA and close > SSpanB
CXS3 = SKijun > SSpanA and SKijun > SSpanB
CXS4 = close > STenkan and close > SKijun
CXS5 = STenkan > SSpanA and STenkan > SSpanB
CXS6 = close > SSpanA[26*ICSell] and close > SSpanB[26*ICSell]
CXS7 = close > STenkan[26*ICSell] and close > SKijun[26*ICSell]
ConditionsExitShort = CXS1 and CXS2 and CXS3 and CXS4 and CXS5 and CXS6 and CXS7
//=/ Confirmation Time Sell
if ConditionsSellShort then
CS = 1
elsif ConditionsExitShort then
CS = -1
else
CS = 0
endif
CTS1 = CS[1] = 1
CTS2 = CS[2] = 1
CTS3 = (open-close) > (close-low)
CTS = CTS1 and CTS2 and CTS3
if CTS then
ConfirmationTimeSell = 1
else
ConfirmationTimeSell = 0
endif
//=/ Sell Short
if NoTrade = 0 and SellActivation = 1 and TTime and ConditionsSellShort and ConfirmationTimeSell = 1 then
SellShort Lotss Contract at Market
Set Stop %Loss 1.09
endif
//=/ Exit Short
if NoTrade = 1 or close > SKijun and close < PositionPrice or ConditionsExitShort then
ExitShort at Market
endif
//
//=/===============/=//=/===============/=//=/ End
//
//
//=/===============/=//=/ IV mcm
//
thanks for that, looks interesting – can you post the results with all money management turned off to get a better idea of the level performance?
Thanks a lot for this new idea, I moved your post into the forum to discuss about, because it would attract a lot of questions in the library because of its optimization settings. Did you made some OOS testing?
Hello Nicolas
No indeed, the OOS tests were not performed for the simple reason that I don’t know how to do it, could you tell me how to proceed?
Thank you
Hello nonetheless
The strategy is developed with system management, so for a fixed batch system, you should probably review the parameters to get more conclusive results.
Sincerely yours,
Use the walk forward tool in the platform in order to test your optimization over an out of sample period (OOS period). You should always divide your backtest history when optimizing, into 2 parts, the first one to optimize the value (In-Sample period = IS) and the second one to test those variables values into “real” market conditions, the OOS period. There are so many topics discussing strategy robustness over the forums, you should dig into them 🙂
Hello IV Mcm,
did you test your strategu with Walkforward ?
Here’s a version of this with no MM, optimized 70/30
Not too bad (apart from 2 awful months) … but unfortunately I’m getting the dreaded Negative/Zero Parameter error in demo.
Most grateful to anyone with any thoughts on this.
DefParam CumulateOrders = False
//
//=/===============/=//=/===============/=//=/ Activation Settings
//
BuyActivation = 1
SellActivation = 1
//
//=/===============/=//=/===============/=//=/ Time Settings
//
Before = Time >= 080000
After = Time < 213000
TTime = Before and After
//
//=/===============/=//=/===============/=//=/ Indicator Settings
//=/ Ichimoku Buy
ICBuy = 1.15
BSpanA = (BTenkan[26*ICBuy]+BKijun[26*ICBuy])/2
BTenkan = (highest[9*ICBuy](high)+lowest[9*ICBuy](low))/2
BKijun = (highest[26*ICBuy](high)+lowest[26*ICBuy](low))/2
BSpanB = (highest[52*ICBuy](high[26*ICBuy])+lowest[52*ICBuy](low[26*ICBuy]))/2
//=/ Ichimoku Sell
ICSell = 0.9
SSpanA = (STenkan[26*ICSell]+SKijun[26*ICSell])/2
STenkan = (highest[9*ICSell](high)+lowest[9*ICSell](low))/2
SKijun = (highest[26*ICSell](high)+lowest[26*ICSell](low))/2
SSpanB = (highest[52*ICSell](high[26*ICSell])+lowest[52*ICSell](low[26*ICSell]))/2
MA = average[36,5](typicalprice)
MAS = average[53,4](typicalprice)
//=/===============/=//=/===============/=//=/ Buy Settings
//
//=/ Conditions Buy
CB1 = momentum[9] > 0
CB2 = momentum[45] > 0
CB3 = momentum[160] > 0
CB4 = close > BSpanA and close > BSpanB
CB5 = BKijun > BSpanA and BKijun > BSpanB
CB6 = close > BTenkan and close > BKijun
CB7 = BTenkan > BSpanA and BTenkan > BSpanB
CB8 = close > BSpanA[26*ICBuy] and close > BSpanB[26*ICBuy]
CB9 = close > BTenkan[26*ICBuy] and close > BKijun[26*ICBuy]
CB10 = ma > ma[1]
ConditionsBuy = CB1 and CB2 and CB3 and CB4 and CB5 and CB6 and CB7 and CB8 and CB9 and CB10
//=/ Conditions Sell
CXB1 = close < open
CXB2 = close < BSpanA and close < BSpanB
CXB3 = BKijun < BSpanA and BKijun < BSpanB
CXB4 = close < BTenkan and close < BKijun
CXB5 = BTenkan < BSpanA and BTenkan < BSpanB
CXB6 = close < BSpanA[26*ICBuy] and close < BSpanB[26*ICBuy]
CXB7 = close < BTenkan[26*ICBuy] and close < BKijun[26*ICBuy]
ConditionsSell = CXB1 and CXB2 and CXB3 and CXB4 and CXB5 and CXB6 and CXB7
//=/ Confirmation Time Buy
if ConditionsBuy then
CB = 1
elsif ConditionsSell then
CB = -1
else
CB = 0
endif
CTB1 = CB[1] = 1
CTB2 = CB[2] = 1
CTB3 = CB[3] = 1
CTB4 = CB[4] = 1
CTB5 = CB[5] = 1
CTB6 = CB[6] = 1
CTB7 = (close-open) > (high-close)
CTB = CTB1 and CTB2 and CTB3 and CTB4 and CTB5 and CTB6 and CTB7
if CTB then
ConfirmationTimeBuy = 1
else
ConfirmationTimeBuy = 0
endif
//=/ Buy
if BuyActivation = 1 and TTime and ConditionsBuy and ConfirmationTimeBuy = 1 then
Buy 1 Contract at Market
Set Stop %Loss 1.4
SET TARGET %PROFIT 1.5
endif
//=/ Sell
if close < BKijun and close > PositionPrice or ConditionsSell then
Sell at Market
endif
//
//=/===============/=//=/===============/=//=/ Sell Settings
//
//=/ Conditions Sell Short
CS1 = close < open
CS2 = momentum[22] < 0
CS3 = momentum[170] < 0
CS4 = momentum[230] < 0
CS5 = close < SSpanA and close < SSpanB
CS6 = SKijun < SSpanA and SKijun < SSpanB
CS7 = close < STenkan and close < SKijun
CS8 = STenkan < SSpanA and STenkan < SSpanB
CS9 = close < SSpanA[26*ICSell] and close < SSpanB[26*ICSell]
CS10 = close < STenkan[26*ICSell] and close < SKijun[26*ICSell]
CS11 = mas < mas[1]
ConditionsSellShort = CS1 and CS2 and CS3 and CS4 and CS5 and CS6 and CS7 and CS8 and CS9 and CS10 and CS11
CXS1 = close > open
CXS2 = close > SSpanA and close > SSpanB
CXS3 = SKijun > SSpanA and SKijun > SSpanB
CXS4 = close > STenkan and close > SKijun
CXS5 = STenkan > SSpanA and STenkan > SSpanB
CXS6 = close > SSpanA[26*ICSell] and close > SSpanB[26*ICSell]
CXS7 = close > STenkan[26*ICSell] and close > SKijun[26*ICSell]
ConditionsExitShort = CXS1 and CXS2 and CXS3 and CXS4 and CXS5 and CXS6 and CXS7
//=/ Confirmation Time Sell
if ConditionsSellShort then
CS = 1
elsif ConditionsExitShort then
CS = -1
else
CS = 0
endif
CTS1 = CS[1] = 1
CTS2 = CS[2] = 1
CTS3 = (open-close) > (close-low)
CTS = CTS1 and CTS2 and CTS3
if CTS then
ConfirmationTimeSell = 1
else
ConfirmationTimeSell = 0
endif
//=/ Sell Short
if SellActivation = 1 and TTime and ConditionsSellShort and ConfirmationTimeSell = 1 then
SellShort 1 Contract at Market
Set Stop %Loss 1.1
SET TARGET %PROFIT 1.6
endif
//=/ Exit Short
if close > SKijun and close < PositionPrice or ConditionsExitShort then
ExitShort at Market
endif
//MFE exit
ONCE MFEx = 0
if mfex then
MFE = summation[barindex-tradeindex](positionperf > 0)
IF longonmarket and barindex-tradeindex > 9 and (MFE = 0) then
sell at market
endif
endif
No Walkforward :/
Not sure what you mean. The optimization is 70/30, so almost 3 years OOS.
But the Negative/Zero Parameter is the bigger problem as it won’t run as it is.
You will notice that the version without MM loses a lot in gain.
The MM allows you to adapt to the volatility to avoid ruining yourself during a crack or gaining nothing during low volatility.
I am all in favour of MM, but for backtest and optimization it’s better to run with level stakes so you know what you’re dealing with. Also easier to compare performance with other algos. MM is added after.
Here’s another version, lower profit but more trades and better %win. Also fixes the zero parameter problem.
2nd image is with my MM code.
Nice algo. I changed some variables. Backtested it since 13.03.2019
Hi, would you like to post your set of variables / algo including it ?
Hi, would you like to post your set of variables / algo including it ?
If yr post was adressed to me, pls find attached the itf file.
Ichimoku Dax M15 automatic trading strategy
This topic contains 17 replies,
has 6 voices, and was last updated by nonetheless
4 years, 10 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 10/26/2020 |
| Status: | Active |
| Attachments: | 9 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.