Ichimoku Trading system – my 1st attempt
Forums › ProRealTime English forum › ProOrder support › Ichimoku Trading system – my 1st attempt
- This topic has 39 replies, 7 voices, and was last updated 7 years ago by
juanj.
-
-
07/31/2017 at 9:10 AM #42054
@bmentink, with regards to the RSI Divergence check and ADX volatility check. It could be that we used different versions of CL or time frames (or any other factor). I will paste the version of the code I used as soon as I can access my platform again (there seems to be technical difficulties at IG). However you can try to optimize the variables yourself, as I can guarantee you it works. With regards to my suggestion regarding SSpanA/B your code would not be compatible with the suggested formulation as you are focusing on the Kumo Break, which is 26 periods back from the leading edge. The leading edge is almost used in a similar fashion to the Kumo Twist, however looking at the leading edges of the cloud and not the Tenkansen and Kijunsen. Thus if calculated the way I suggested, the Kumo break would be determined at SSpanA[26].
07/31/2017 at 3:36 PM #4210507/31/2017 at 6:28 PM #42123Hi Jessar,
Both of us are quiet new here but the following link might help you : https://www.prorealcode.com/import-export-prorealtime-code-platform/
I use import button, and the files are located on your download section on Windows…Then import…Very easy.
07/31/2017 at 9:00 PM #4213508/01/2017 at 5:07 PM #4224808/01/2017 at 5:59 PM #42256@jessar the code was configured/set for a specific market (in this case CL) and time frame. If you use it on another Market or Time frame you would need to optomize/set the different variables using the backtest engine of Prorealtime.
08/02/2017 at 6:24 AM #4228008/04/2017 at 7:52 AM #4246208/04/2017 at 8:20 AM #42464@bmentink apologies. I forgot about your request to post the code. Here it is along with my result on CL (US Crude on 10min with spread set to 2.8):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160// IchiMoku/EMA Slope trading system ... by Bernard Mentink// Version 1.0// If you make improvements. Please Change the version number above and the strategy filename, (So we can keep track)// I will keep my copies under "git" versioning.defparam cumulateorders = falseDEFPARAM Preloadbars = 200// ---------------------------------- Variables ----------------------------------------BOK = 0NbrContracts = 1SlopeThreshold = 3.9 // From back/forward testing optimizationTGL = 32 // also from back/forward testing, note TGL and TGS the same,TGS= TGL // we don't want to bias for the current market (bull/bear) - because it could change at any time.ATR = AverageTrueRange[5](close) //Average TRue Range calculated over the last x periodsTP = ATR*9 //Profit TargetSL = ATR*7 //Stoploss// ---------------------------------- Indicators --------------------------------------// IchimokuTenkansen = (highest[9](high)+lowest[9](low))/2Kijunsen = (highest[26](high)+lowest[26](low))/2SSpanA = (tenkansen[26]+kijunsen[26])/2SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2Chikou = close[26]// This indicator calculates linear regression slope of moving average input, > 0 positive slope, <0 negative// calculated on last 2 barslength = 2SumBars = Length * (Length-1) * 0.5SumSqrBars = (Length-1) * Length * (2 * Length-1) / 6if(barindex>Length) thenSum1 = 0SumY=0MA = DEMA(close)for i=0 to Length-1 doSum1 = Sum1+(i*MA[i])SumY = SumY+(MA[i])nextSum2 = SumBars * SumYNum1 = Length * Sum1 - Sum2Num2 = SumBars * SumBars - Length * SumSqrBarsendifRegSlope = Num1/Num2myslope = RegSlope / close * 10000 // Scale slope to instrument.// ---------------------------------- The code ---------------------------------------// This is the meat, The key I think is in the slope. Adding the slope code improved the profitability greatly.// Looking at the Chikou also helped keep us in the proper trend.// Note carefully the comparisons are different depending on bull/bear of the Kumo.// Our Ichimoku conditions broken down:// Shortcs1 = close < SSpanA and close[1] > SSpanA[1]cs2 = close < Kijunsen and close < Chikoucs3 = mySlope > -SlopeThresholdcs4 = mySlope < -SlopeThresholdcs5 = close < SSpanB and close[1] > SSpanB[1]// Longcl1 = close > SSpanB and close[1] < SSpanB[1]cl2 = close > Kijunsen and close > Chikoucl3 = mySlope < SlopeThresholdcl4 = mySlope > SlopeThresholdcl5 = close > SSpanA and close[1] < SSpanA[1]// Ichimoku logicIF SSpanB > SSpanA THEN// BREAK OUT KUMO downif cs1 and cs2 and cs3 thenBOK = -1else// BREAK OUT KUMO upif cl1 and cl2 and cl3 thenBOK = 1endifendifelse// BREAK OUT KUMO upif cl5 and cl2 and cl4 thenBOK = 1else// BREAK OUT KUMO downif cs5 and cs2 and cs4 thenBOK = -1endifendifENDIF// ------------------------------- Additional Criteria -----------------------------------R = RSI[25](close) //RSI Period to determine momentumIf R > R[26] ThenIf close < close[26] ThenBDIV = 1 //Possible Bearish Divergence PresentSDIV = 0EndIfEndIfIf R < R[26] ThenIf close > close[26] ThenSDIV = 1 //Possible Bullish Divergence PresentBDIV = 0EndIfEndIfAX = ADX[19] > 15// ---------------------------------- Market Stuff --------------------------------------if BOK=-1 and BDIV = 0 and AX thensellshort NbrContracts contract at marketendifif BOK=1 and SDIV = 0 and AX thenbuy NbrContracts contract at marketendif// ---------------------------------- Stops ----------------------------------------------//TRAILING STOPif not onmarket thenMAXPRICE = 0MINPRICE = closeEXITPRICE = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenEXITPRICE = MAXPRICE-TGL*pointsizeENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenEXITPRICE = MINPRICE+TGS*pointsizeENDIFENDIFif onmarket and EXITPRICE>0 thenEXITSHORT AT EXITPRICE STOPSELL AT EXITPRICE STOPENDIF// Mostly as a safety stop, although it creats greater profits on a ranging market, good to optimize the "970" for the instrument.// We still need a better stop if market moves against us shortly after entry and before the trailing stop comes into play.set stop ploss SLset target pprofit TPNote this only inludes the RSI Divergence and ADX checks not the leading edge check for SSpanA/B as that requires slightly more of a re-write.
08/04/2017 at 8:25 AM #42466 -
AuthorPosts