Weekly Ichimoku System

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47034 quote
    grimweasel47
    Participant
    Senior

    Hi Guys.

    I’m testing a system that uses daily or weekly charts (in this case weekly). The conditions are that price must be above/below the Kijun with Kijun going up(long) or down(short). Further price must cross over the ‘cloud’ and only then an order is placed above the highest high (n) periods and lowest low (n) periods for short.  For some reason the system won’t backtest – keeps reporting an error. Could this be due to Sat morning maintenance on the platform?

    Thanks

    defparam cumulateorders=false
    
    // --- settings
    balance = 10000 //balance of the strategy when activated the first time
    minlot = 1 //minimum lot size for the current instrument (example: 1 for DAX)
    riskpercent = 2 //risk percent per trade
    atr = averagetruerange(21)
    hh = highest[21](high)
    ll = lowest[21](low)
    
    // Long
    p1=13
    p2=26
    //p3=63
    p4=26
    tenkan=(highest[p1](high)+lowest[p1](low))/2
    kijun=(highest[p2](high)+lowest[p2](low))/2
    
    SpanA=(tenkan[p4]+kijun[p4])/2
    //SpanB=(highest[p3](high[p4])+lowest[p3](low[p4]))/2
    
    //c3=close[0] crosses over spana and close[0] crosses over spanb
    //c4=close[0] crosses over kijun and close[0]>open[0]
    x=close > kijun
    x1=close crosses over spana
    x2= kijun > kijun[1]
    
    ///short
    p1=13
    p2=26
    //p3=63
    p4=26
    tenkan=(highest[p1](high)+lowest[p1](low))/2
    kijun=(highest[p2](high)+lowest[p2](low))/2
    
    SpanA=(tenkan[p4]+kijun[p4])/2
    //SpanB=(highest[p3](high[p4])+lowest[p3](low[p4]))/2
    
    //c5=close[0] crosses under spana and close[0] crosses under spanb
    //c6=close[0]crosses under kijun and close[0]<open[0]
    y=close < kijun
    y1=close[0] crosses under Spana
    y2= kijun < kijun[1]
    finalcondition1 = x and x1 and x2
    finalcondition2 = y and y1 and y2
    
    ////
    if intradaybarindex=0 then
    alreadytraded = 0
    case = 0
    levelhi = 0
    levello = 0
    endif
    
    if onmarket or (onmarket[1] and not onmarket) or (currentprofit<>strategyprofit) then
    alreadytraded = 1
    endif
    
    //case 1 : If price is above the Ichy then only trade long BUT only above the highest high of the past 21 weeks
    
    if finalcondition1 then
    case = 1
    levelhi = hh[1]
    //levelhi = CALL"#floor and ceil"[high,0.10,1]
    //levello = CALL"#floor and ceil"[low,0.10,-1]
    endif
    
    //case 2 : If price is above the Ichy then only trade short BUT only below the lowest low  of the past 21 weeks
    if finalcondition2 then
    case = 2
    levello = ll[1]
    endif
    
    ///
    if alreadytraded = 0 then
    //money management
    StopLoss = 1*ATR
    endif
    
    Risk = riskpercent/100
    //calculate contracts
    equity = balance + StrategyProfit
    maxrisk = round(equity*Risk)
    size = max(minlot,abs(round((maxrisk/StopLoss)/PointValue)*pipsize))
    //in all cases put pending orders on market
    while case <> 0  do
    if levelhi>0 then
    buy size contract at levelhi stop
    endif
    if levello>0 then
    sellshort size contract at levello stop
    endif
    wend
    
    //set target and profit
    if onmarket  then
    set target profit 3*ATR
    set stop loss StopLoss
    endif
    
    
    currentprofit = strategyprofit
    
    //debugging
    //graph case as "case"
    
    #47353 quote
    Nicolas
    Keymaster
    Master

    I think your problem is due to the period error at line 7 of your code, the average true range period should be coded this way:

    atr = averagetruerange[21]
    #47371 quote
    grimweasel47
    Participant
    Senior

    Thanks Nicolas – such a silly error! I will edit and report back. Thanks again!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Weekly Ichimoku System


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by grimweasel47
8 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/23/2017
Status: Active
Attachments: No files
Logo Logo
Loading...