Ichimoku Trading system – my 1st attempt

Viewing 10 posts - 31 through 40 (of 40 total)
  • Author
    Posts
  • #42054 quote
    juanj
    Participant
    Master

    @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].

    #42105 quote
    Jessar
    Participant
    Senior

    Hi folks, with which program do I have to open the strategy to be able to test them themselves? I get only very funny characters when I open it with Word, am still new in the forum.

    Mfg Jessar

    #42123 quote
    Inertia
    Participant
    Master

    Hi 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.

    #42135 quote
    Jessar
    Participant
    Senior

    Thank you trägheit, it is realy easy 🙂

    #42248 quote
    Jessar
    Participant
    Senior

    I get this code simply not set so I get good results, I make something wrong or I just do not understand it?

    #42256 quote
    juanj
    Participant
    Master

    @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.

    #42280 quote
    Jessar
    Participant
    Senior

    I can make it synonymous unfortunately with the program does not set this code on EurJpy positively, one must also adjust the ichimoku anew? Lg 10min eurjpy

    #42462 quote
    bmentink
    Participant
    Average

    @juanj Still waiting for your version of the code…. 🙂 🙂

    #42464 quote
    juanj
    Participant
    Master

    @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):

    // 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 = false
    DEFPARAM Preloadbars = 200
    
    // ---------------------------------- Variables ----------------------------------------
    BOK = 0
    NbrContracts = 1
    SlopeThreshold =  3.9 // From back/forward testing optimization
    TGL = 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 periods
    TP = ATR*9 //Profit Target
    SL = ATR*7 //Stoploss
    
    // ---------------------------------- Indicators --------------------------------------
    
    // Ichimoku
    Tenkansen = (highest[9](high)+lowest[9](low))/2
    Kijunsen = (highest[26](high)+lowest[26](low))/2
    SSpanA = (tenkansen[26]+kijunsen[26])/2
    SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
    Chikou = close[26]
    
    
    // This indicator calculates linear regression slope of moving average input, > 0 positive slope, <0 negative
    // calculated on last 2 bars
    length = 2
    SumBars = Length * (Length-1) * 0.5
    SumSqrBars = (Length-1) * Length * (2 * Length-1) / 6
    
    if(barindex>Length) then
    Sum1 = 0
    SumY=0
    MA = DEMA(close)
     
    for i=0 to Length-1 do
    Sum1 = Sum1+(i*MA[i])
    SumY = SumY+(MA[i])
    next
     
    Sum2 = SumBars * SumY
     
    Num1 = Length * Sum1 - Sum2
    Num2 = SumBars * SumBars - Length * SumSqrBars
    endif
     
    RegSlope = Num1/Num2
    myslope = 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:
    // Short
    cs1 = close < SSpanA and close[1] > SSpanA[1]
    cs2 = close < Kijunsen and close < Chikou
    cs3 = mySlope > -SlopeThreshold
    cs4 = mySlope < -SlopeThreshold
    cs5 = close < SSpanB and close[1] > SSpanB[1]
    
    // Long
    cl1 = close > SSpanB and close[1] < SSpanB[1]
    cl2 = close > Kijunsen and close > Chikou
    cl3 = mySlope < SlopeThreshold
    cl4 = mySlope > SlopeThreshold
    cl5 = close > SSpanA and close[1] < SSpanA[1]
    
    
    // Ichimoku logic
    IF SSpanB > SSpanA THEN
    // BREAK OUT KUMO down
    if cs1 and cs2 and cs3 then
    BOK = -1
    else
    // BREAK OUT KUMO up
    if cl1 and cl2 and cl3 then
    BOK = 1
    endif
    endif
    else
    // BREAK OUT KUMO up
    if cl5 and cl2 and cl4 then
    BOK = 1
    else
    // BREAK OUT KUMO down
    if cs5 and cs2 and cs4 then
    BOK = -1
    endif
    endif
    ENDIF
    
    // ------------------------------- Additional Criteria -----------------------------------
    
    R = RSI[25](close) //RSI Period to determine momentum
    
    If R > R[26] Then
    If close < close[26] Then
    BDIV = 1 //Possible Bearish Divergence Present
    SDIV = 0
    EndIf
    EndIf
     
    If R < R[26] Then
    If close > close[26] Then
    SDIV = 1 //Possible Bullish Divergence Present
    BDIV = 0
    EndIf
    EndIf
    
    AX = ADX[19] > 15
    // ---------------------------------- Market Stuff --------------------------------------
    
    if BOK=-1 and BDIV = 0 and AX then
    sellshort NbrContracts contract at market
    endif
    
    if BOK=1 and SDIV = 0 and AX then
    buy NbrContracts  contract at market
    endif
    
    // ---------------------------------- Stops ----------------------------------------------
    
    //TRAILING STOP
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    EXITPRICE = 0
    ENDIF
    
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    EXITPRICE = MAXPRICE-TGL*pointsize
    ENDIF
    ENDIF
    
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    EXITPRICE = MINPRICE+TGS*pointsize
    ENDIF
    ENDIF
    
    if onmarket and EXITPRICE>0 then
    EXITSHORT AT EXITPRICE STOP
    SELL AT EXITPRICE STOP
    ENDIF
    
    // 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 SL
    set target pprofit TP
    

    Note 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.

    BmentinkCL.jpg BmentinkCL.jpg
    #42466 quote
    juanj
    Participant
    Master

    And maybe just for comparison, here is my result without the RSI Divergence and ADX checks, using the original code.

    BmentinkCL-Before.jpg BmentinkCL-Before.jpg
Viewing 10 posts - 31 through 40 (of 40 total)
  • You must be logged in to reply to this topic.

Ichimoku Trading system – my 1st attempt


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
bmentink @bmentink Participant
Summary

This topic contains 39 replies,
has 7 voices, and was last updated by juanj
8 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/24/2017
Status: Active
Attachments: 12 files
Logo Logo
Loading...