ICHIMOKU code problems

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #102872 quote
    trevor
    Participant
    Senior

    Sorry to be posting this here but cannot access the community forum.

    When preparing for trading the issue with defined variables stops me from trading. The variables are defined as you can see from the attachment.

    The following, is the code I want to use. Could someone please help me to sort out the undefined variable conflict? It would help if proRealTime highlighted the error in the code. I have defined all the variables within any [ ] brackets.

    /LINK https://www.prorealcode.com/prorealtime-trading-strategies/ichimoku-exits-cloud/

    //Source idea: https://www.whselfinvest.nl/nl-nl/trading-platform/gratis-trading-strategie/tradingsysteem/17-ichimoku-tkc
    Defparam CumulateOrders = false // Cumulating positions deactivated
    //Defparam flatafter = 164500
    
    //once StartE = 080000 //start time for opening positions
    //once StartL = 160000 //ending time for opening positions (only trading in the morning)
    once N = 2 // intitial number of contracts
    OTD = Barindex - TradeIndex(5) > IntradayBarIndex // limits the (opening) trades till 1 per day
    once Spread = 6 //total spread buy and sell, the actual price is always in between !
    once SL = round(close * 100/10000) //Setting Stop loss //Dynamic for indices
    
    // Ichimoku settings
    TenkanSen = (highest[S](high)+lowest[S](low))/2 // default setting S = 9
    KijunSen = (highest[M](high)+lowest[M](low))/2 // default setting M = 26
    SenkouSpanA = (Tenkansen[M]+Kijunsen[M])/2 // default setting M = 26
    SenkouSpanB = (highest[L](High[M])+lowest[L](Low[M]))/2 //default setting L = 52
    
    // Closing methodes (described for long positions, for short positions exactly the opposite
    //Method 1 if TenkanSen crosses under the Kijunsen
    //Method 2 if close closes under the upper side of the Kumo / Cloud, based upon the SenkouSpanA
    //Method 3 if close closes under the lower side of the Kumo / Cloud, based upon the SenkouSpanB
    ClosingMethod = cm //default is cm = 1
    
    //Open LONG BUY conditions (2):
    // 1: Tenkan Sen crosses over the Kijun Sen AND
    // 2: Close is within 4 periods after the crossing above the Kumo (cloud), defined as Max(SenkouSpanA, SenkouSpanB) /
    
    //Open SHORT SELL conditions (2):
    // 1: Tenkan Sen crosses under the Kijun Sen AND
    // 2: Close is within 4 periods after the crossing BELOW the Kumo (cloud), defined as Min(SenkouSpanA, SenkouSpanB) /
    
    KumoBorderLong = Max(SenkouSpanA, SenkouSpanB) //
    KumoBorderShort = Min(SenkouSpanA, SenkouSpanB) //
    //graph KumoBorderShort
    If TenkanSen crosses over KijunSen then // base for counting bars when crossing takes place
    CondLong = 1
    else
    CondLong = 0
    endif
    If TenkanSen crosses under KijunSen then
    CondShort = 1
    else
    CondShort = 0
    endif
    //graph cond1L
    if OTD and not onmarket then
    IF summation[4](CondLong) = 1 and summation[4](CondShort) = 0 and Close > KumoBorderLong then //
    BUY N shares AT MARKET
    SET STOP ploss SL
    endif
    IF summation[4](CondLong) = 0 and summation[4](CondShort) = 1 and Close < KumoBorderShort THEN //
    SELLSHORT N shares AT MARKET //short sell conditie
    SET STOP pLOSS SL
    endif
    endif // end purchase conditions
    
    if not onmarket then
    PriceExit = 0
    endif
    if longonmarket then // 3 Exit strategies
    if ClosingMethod = 1 then
    If TenkanSen crosses under KijunSen then
    sell at market
    endif
    endif
    if ClosingMethod = 2 then
    if close - Spread * 0.5 < KumoBorderShort then //to secure a possible stop for Sell at market
    PriceExit = close - Spread * 0.5
    else
    PriceExit = KumoBorderShort // regular STOP for sell at market, set for each trading bar
    endif
    endif
    if ClosingMethod = 3 then
    if close - Spread * 0.5 < KumoBorderLong then //to secure a possible stop for Sell at market
    PriceExit = close - Spread * 0.5
    else
    PriceExit = KumoBorderShort // regular STOP for sell at market, set for each trading bar
    endif
    endif
    endif
    
    if shortonmarket then //// 3 Exit strategies
    if ClosingMethod = 1 then
    If TenkanSen crosses over KijunSen then
    exitshort at market
    endif
    endif
    if ClosingMethod = 2 then
    if close + Spread * 0.5 > KumoBorderLong then //to secure a possible stop for Sell at market
    PriceExit = close + Spread * 0.5
    else
    PriceExit = KumoBorderLong // regular STOP for EXIT SHORT at market, set for each trading bar
    endif
    endif
    if ClosingMethod = 3 then
    if close + Spread * 0.5 > KumoBorderShort then //to secure a possible stop for Sell at market
    PriceExit = close + Spread * 0.5
    else
    PriceExit = KumoBorderShort // regular STOP for EXIT SHORT at market, set for each trading bar
    endif
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then //price exit set for each trading bar
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    //graph priceexit
    variables-snapshot-1563492553pc8l4.jpg variables-snapshot-1563492553pc8l4.jpg
    #103130 quote
    Nicolas
    Keymaster
    Master

    Undefined variables means that they are not present in the code (or commented with either a double slash // or with REM instruction). So remove the double slash and REM from the code in order to get the variables to be defined.
    Another way is to download the file in the library and import it into the platform instead of copy/pasting it.

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

ICHIMOKU code problems


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Nicolas
6 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/22/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...