Ichimoku + stochastic strategy, help needed

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #131982 quote
    deleted23092025
    Participant
    New

    Hi,

    Im trying to build an tradebot and I´m trying to learn.

    This is what I´m working with:

    // --- settings
    KPeriod = 25
    Slowing = 3
    DPeriod = 3
    ATRperiod = 20
    maPeriod = 20
    maMethod = 0
    overBought = 80
    overSold = 20
    // --- end of settings
    
    myRSI = RSI[14](close)
    
    //Smoothing the RSI value on 10 periods
    SmoothRSI = Average[10](myRSI)
    
    RETURN myRSI, SmoothRSI coloured(121,45,180)
    
    // --- Property settings
    DefParam DrawOnLastBarOnly = true
    // Price = 1 // (1=true/0=false)
    // Kijun = 1 // ------
    // Cloud = 1 // ------
    // Lagging = 1 // ------
    // Label = 1 // ------
    // --- end
    
    Tenkansen = (highest[9](High)+lowest[9](Low))/2
    Kijunsen = (highest[26](High)+lowest[26](Low))/2
    //Chikou = Close[26]
    SenkouSA = (Tenkansen[26]+Kijunsen[26])/2
    SenkouSB = (highest[52](High[26])+lowest[52](Low[26]))/2
    
    // short
    stochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)
    rsiSignal = change(rsi) < 0
    ichiSellSignal = chikou < sourceInput[chikouDisplacement-1]
    
    sellSignal = stochSellSignal and rsiSignal and ichiSellSignal
    
    shortProfitPerc = input(title="Short Take Profit (%)", minval=0.0, step=0.1, defval=0.6) / 100
    shortLossPerc = input(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=0.5) / 100

    I know its not working and I would need some guidelines from you guys here how to keep going on. Much thanks!

    ,,

    #131988 quote
    robertogozzi
    Moderator
    Master
    Stick to highlighted basic rules, among which:

    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.

    it doesn’t work because it’s not written in ProRealTime language, at least the last two lines (provided the first ones have been correctly converted). Maybe someone knowing that language might help.
    #131992 quote
    Vonasi
    Moderator
    Master
    Plus you have a DEFPARAM in the middle of the code and it should always be at the beginning and you have a RETURN in the middle of the code when it should always be at the end. You say you are building a ‘tradebot’ but this is an indicator that you are working on and not an auto strategy.
    #132759 quote
    deleted23092025
    Participant
    New
    // Definition of code parameters
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    DEFPARAM preloadbars = 5000
    //Money Management Dax
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize=2
    ENDIF
    if MM = 1 then
    ONCE startpositionsize = 1
    ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
    ONCE factor2 = 20 // tier 2 factor
    ONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE tier1 = 105 // DAX €1 IG first tier margin limit
    ONCE maxpositionsize = 1050 // DAX €1 IG tier 2 margin limit
    ONCE minpositionsize = 1 // enter minimum position allowed
    IF Not OnMarket THEN
    positionsize = startpositionsize + Strategyprofit/(factor*margin)
    ENDIF
    IF Not OnMarket THEN
    IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
    positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 //incorporating tier 2 margin
    ENDIF
    IF Not OnMarket THEN
    if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
    positionsize = minpositionsize //keeps positionsize from going below allowed minimum
    ENDIF
    IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize then
    positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    Ctime = time >= 090000 and time < 173000
    // --- stochastic
    mySMI = SmoothedStochastic[14,3](close)
    
    // --- rsi
    myRSI = RSI[14](close)
    
    // --- ichimoku cloud
    
    Tenkansen = (highest[9](High)+lowest[9](Low))/2
    Kijunsen = (highest[26](High)+lowest[26](Low))/2
    //Chikou = Close[26]
    SenkouSA = (Tenkansen[26]+Kijunsen[26])/2
    SenkouSB = (highest[52](High[26])+lowest[52](Low[26]))/2
    #132760 quote
    deleted23092025
    Participant
    New
    Thanks for the help guys. I hope I´m learing in the right direction. Can someone help me set up the short condition:
    // short
    stochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)
    rsiSignal = change(rsi) < 0
    ichiSellSignal = chikou < sourceInput[chikouDisplacement1]
    sellSignal = stochSellSignal and rsiSignal and ichiSellSignal
    This easily means short when stochasticfast  > 80 and cross under (stochFast, stochSlow)
    rsi is moving down
    close is less than chikou (lagging span)
    And all of them together to short.
    #132764 quote
    robertogozzi
    Moderator
    Master
    As it is coded it will work on v11, since it has Ichimoku keywords that are missing in v10.3 (but can be easily replaced). Now you only need to write the code to enter and exit trades.
    thanked this post
    #132788 quote
    deleted23092025
    Participant
    New
    Oh I have v10.3 this is the condition for enter short trade
    // short
    stochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)
    rsiSignal = change(rsi< 0
    ichiSellSignal = chikou < sourceInput[chikouDisplacement1]
    sellSignal = stochSellSignal and rsiSignal and ichiSellSignal
    This easily means short when stochasticfast  > 80 and cross under (stochFast, stochSlow)
    rsi is moving down
    close is less than chikou (lagging span)
    Im just unsure how to write them in prt and I would like some help with that from someone here at the forum 😀
    #132939 quote
    robertogozzi
    Moderator
    Master
    There you go. I commented unused Ichimoku definitions and added TP & SL to make it work for testing purposes:
    // Definition of code parameters
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    DEFPARAM preloadbars = 5000
    ONCE startpositionsize = 1
    ONCE factor            = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
    ONCE factor2           = 20 // tier 2 factor
    ONCE margin            = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE margin2           = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE tier1             = 105 // DAX €1 IG first tier margin limit
    ONCE maxpositionsize   = 1050 // DAX €1 IG tier 2 margin limit
    ONCE minpositionsize   = 1 // enter minimum position allowed
    //Money Management Dax
    MM = 0    // = 0 for optimization
    if MM = 0 then
       positionsize=2
    ELSE
       IF Not OnMarket THEN
          positionsize = startpositionsize + Strategyprofit/(factor*margin)
          IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
             positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 //incorporating tier 2 margin
             if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
                positionsize = minpositionsize //keeps positionsize from going below allowed minimum
             ENDIF
             IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize then
                positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit
             ENDIF
          ENDIF
       ENDIF
    ENDIF
    Ctime = time >= 090000 and time < 173000
    // --- stochastic
    mySMIk = SmoothedStochastic[14,3](close)
    mySMId = average[5](mySMIk)
    // --- rsi
    myRSI = RSI[14](close)
    // --- ichimoku cloud
    //
    //Tenkansen = (highest[9](high)  + lowest[9](low))  / 2          //Fast MA
    //Kijunsen  = (highest[26](high) + lowest[26](low)) / 2          //Slow MA
    //SenkouSA  = (tenkansen[26] + kijunsen[26]) / 2                 //Span A
    //SenkouSB  = (highest[52](high[26]) + lowest[52](low[26])) / 2  //Span B
    Chikou      = close[26]                                          //Chikou
    //
    c1 = mySMIk > 80
    c2 = mySMIk CROSSES UNDER mySMId
    c3 = myRSI < myRSI[1]
    c4 = close < Chikou
    IF c1 AND c2 AND c3 AND c4 AND Not Onmarket AND cTime THEN
       SELLSHORT PositionSize contract at Market
       Set Target pProfit 100
       Set Stop   pLoss   50
    ENDIF
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Ichimoku + stochastic strategy, help needed


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by robertogozzi
5 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/17/2020
Status: Active
Attachments: No files
Logo Logo
Loading...