RSI and IBS based EA

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #53719 quote
    Marc
    Participant
    Average

    Hi together,
    I’d like to share my code with you and want to know if there is any mistake within this code?
    Thank you in advance

    Here are the rules for this system:
    Enter Long when:

    • When RSI with Period 2 is below or equal 10 on previous periods close
    • When RSI with Period 2 is above or equal 10 at close of current periods close
    • When IBS is below or equal 50 on previous periods close
    • When IBS is above or equal 50 at close of current period
    • Open Long at next bar open

    Exit Long when:

    • RSI rises above 80 at close of previous period, close position at next bar open

    Enter Short when:

    • When RSI with Period 2 is above or equal 90 on previous periods close
    • When RSI with Period 2 is below or equal 90 at close of current periods close
    • When IBS is above or equal 50 on previous periods close
    • When IBS is below or equal 50 at close of current period
    • Open Short at next bar open

    Exit Short when:

    • RSI falls below 20 at close of previous period, close position at next bar open

    Here is the code:

    //INDICATORIBS = (Close-Low) / (HIGH-LOW) * 100RSI2 = RSI[2](close)
    //SIGNALIBSLONGTRIGGER = 50IBSSHORTTRIGGER = 50
    RSILONGTRIGGER = 10RSILONGEXIT = 80RSISHORTTRIGGER = 90RSISHORTEXIT = 20
    //ENTRY CONDITIONl1 = not LongOnMarketl1 = l1 and IBS[1] >= IBSLONGTRIGGER[1]l1 = l1 and IBS[2] <= IBSLONGTRIGGER[2]l1 = l1 and RSI2[1] >= RSILONGTRIGGER[1]l1 = l1 and RSI2[2] <= RSILONGTRIGGER[2]
    b1 = not ShortOnMarketb1 = b1 and IBS[1] <= IBSSHORTTRIGGER[1]b1 = b1 and IBS[2]>= IBSSHORTTRIGGER[2]b1 = b1 and RSI2[1] <= RSISHORTTRIGGER[1]b1 = b1 and RSI2[2] >= RSISHORTTRIGGER[2]
    //EXIT CONDITIONl2 = LongOnMarketl2 = l2 and RSI2[1] >= RSILONGEXIT[1]
    b2 = ShortOnMarketb2 = b2 and RSI2[1] <= RSISHORTEXIT[1]
    //LONG ENTRYIF l1 THENBUY 1 CONTRACTS AT MARKET NextBarOpenENDIF
    //LONG EXITIf l2 THENSELL AT MARKET NextBarOpenENDIF
    //SHORT ENRTRYIF b1 THENSELLSHORT 1 CONTRACTS AT MARKET NextBarOpenENDIF
    //SHORT EXITIF b2 THENEXITSHORT AT MARKET NextBarOpenENDIF
    #53733 quote
    victormork
    Participant
    Veteran
    l1 = l1 and IBS >= IBSLONGTRIGGER
    l1 = l1 and IBS[1] <= IBSLONGTRIGGER[1]
    l1 = l1 and RSI2 >= RSILONGTRIGGER
    l1 = l1 and RSI2[1] <= RSILONGTRIGGER[1]

    You should use [1] for previous period and no additional number for  current period.

    Marc thanked this post
    #53735 quote
    Marc
    Participant
    Average

    You should use [1] for previous period and no additional number for current period.

    Hi victormork,
    thank you very much for your help.
    Currently I’m testing this system manual und hope that this will work constantly on other timeframes…
    To enter additional Orders when entry rules are met here is the amended code:

    //INDICATORIBS = (Close-Low) / (HIGH-LOW) * 100RSI2 = RSI[2](close)
    //SIGNALIBSLONGTRIGGER = 50IBSSHORTTRIGGER = 50
    RSILONGTRIGGER = 10RSILONGEXIT = 80RSISHORTTRIGGER = 90RSISHORTEXIT = 20
    //ENTRY CONDITION
    l1 = IBS >= IBSLONGTRIGGERl1 = l1 and IBS[1] <= IBSLONGTRIGGER[1]l1 = l1 and RSI2 >= RSILONGTRIGGERl1 = l1 and RSI2[1] <= RSILONGTRIGGER[1]
    b1 = IBS <= IBSSHORTTRIGGERb1 = b1 and IBS[1]>= IBSSHORTTRIGGER[1]b1 = b1 and RSI2 <= RSISHORTTRIGGERb1 = b1 and RSI2[1] >= RSISHORTTRIGGER[1]
    //EXIT CONDITIONl2 = LongOnMarketl2 = l2 and RSI2[1] > RSILONGEXIT[1]
    b2 = ShortOnMarketb2 = b2 and RSI2[1] < RSISHORTEXIT[1]
    //LONG ENTRYIF l1 THENBUY 1 CONTRACTS AT MARKET NextBarOpenENDIF
    //LONG EXITIf l2 THENSELL AT MARKET NextBarOpenENDIF
    //SHORT ENRTRYIF b1 THENSELLSHORT 1 CONTRACTS AT MARKET NextBarOpenENDIF
    //SHORT EXITIF b2 THENEXITSHORT AT MARKET NextBarOpenENDIF
    #53736 quote
    Marc
    Participant
    Average

    another improvement:

    //INDICATORIBS = (Close-Low) / (HIGH-LOW) * 100RSI2 = RSI[2](close)
    //CONTRACTSIZEX = 3
    //SIGNALIBSLONGTRIGGER = 50IBSSHORTTRIGGER = 50
    RSILONGTRIGGER = 10RSILONGEXIT = 80RSISHORTTRIGGER = 90RSISHORTEXIT = 20
    //ENTRY CONDITIONl1 = NOT LongOnMarketl1 = IBS >= IBSLONGTRIGGERl1 = l1 and IBS[1] <= IBSLONGTRIGGER[1]l1 = l1 and RSI2 >= RSILONGTRIGGERl1 = l1 and RSI2[1] <= RSILONGTRIGGER[1]
    b1 = NOT ShortOnMarketb1 = IBS <= IBSSHORTTRIGGERb1 = b1 and IBS[1]>= IBSSHORTTRIGGER[1]b1 = b1 and RSI2 <= RSISHORTTRIGGERb1 = b1 and RSI2[1] >= RSISHORTTRIGGER[1]
    //EXIT CONDITIONl2 = LongOnMarketl2 = RSI2 > RSILONGEXIT
    b2 = ShortOnMarketb2 = RSI2 < RSISHORTEXIT
    //LONG ENTRYIF l1 THENBUY X CONTRACTS AT MARKET NextBarOpenENDIF
    //LONG EXITIf l2 THENSELL X CONTRACTS AT MARKET NextBarOpenENDIF
    //SHORT ENTRYIF b1 THENSELLSHORT X CONTRACTS AT MARKET NextBarOpenENDIF
    //SHORT EXITIF b2 THENEXITSHORT AT MARKET NextBarOpenENDIF
    #53741 quote
    Marc
    Participant
    Average

    Now with MA as filter….

    INDICATORIBS = (Close-Low) / (HIGH-LOW) * 100
    RSI2 = RSI[2](close)
    MA = average[maperiod](close)
    CONTRACTSIZEX = 10
    //MOVING AVERAGE PERIOD
    maperiod = 144
    SIGNALIBSLONGTRIGGER = 50
    IBSSHORTTRIGGER = 50
    RSILONGTRIGGER = 10
    RSILONGEXIT = 80
    RSISHORTTRIGGER = 90
    RSISHORTEXIT = 20
    //ENTRY CONDITION
    l1 = NOT LongOnMarket
    l1 = l1 and IBS > IBSLONGTRIGGER
    l1 = IBS[1] < IBSLONGTRIGGER[1]
    l1 = l1 and RSI2 > RSILONGTRIGGER
    l1 = RSI2[1] < RSILONGTRIGGER[1]
    l1 = l1 and low[1] > MA
    b1 = NOT ShortOnMarket
    b1 = b1 and IBS < IBSSHORTTRIGGER
    b1 = IBS[1] > IBSSHORTTRIGGER[1]
    b1 = b1 and RSI2 < RSISHORTTRIGGER
    b1 = RSI2[1] > RSISHORTTRIGGER[1]
    b1 = b1 and high [1] < MA
    //EXIT CONDITION
    l2 = LongOnMarketl2 = RSI2 > RSILONGEXIT
    b2 = ShortOnMarketb2 = RSI2 < RSISHORTEXIT
    //LONG ENTRY
    IF l1 THEN
    BUY X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    //LONG EXIT
    If l2 THEN
    SELL X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    //SHORT ENTRY
    IF b1 THEN
    SELLSHORT X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    //SHORT EXIT
    IF b2 THEN
    EXITSHORT AT MARKET NextBarOpen
    ENDIF
    #53796 quote
    jebus89
    Participant
    Master

    What timeframe and what market are you planning this strategy on?
    Interesting results but i would definitly use

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    If not youre getting an INSANE amount of trades 😛 Even without that its basicly in the market at all times. With 5 min timeframe on the dax i get an avg 18 trades pr day hehe.Its not that crazy bad though, 6258 trades in totalt (INSANE and not very good imo) 4000 wins and 2000 loss. Should indicate that its either superlucky, or actually might have a decent entry 🙂

    #53797 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    >> For clarity of messages on ProRealCode’s forums, please use the “<> (insert PRT code)” button in the message editor to separate the text part from the code part! Thank you! <<

    Marc thanked this post
    #53842 quote
    Marc
    Participant
    Average
    What timeframe and what market are you planning this strategy on? Interesting results but i would definitly use // Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated If not youre getting an INSANE amount of trades 😛 Even without that its basicly in the market at all times. With 5 min timeframe on the dax i get an avg 18 trades pr day hehe. Its not that crazy bad though, 6258 trades in totalt (INSANE and not very good imo) 4000 wins and 2000 loss. Should indicate that its either superlucky, or actually might have a decent entry 🙂


    Hi Jebus89,

    the timeframes I’d use are 1H, 2H, 4H and Daily. 

    Thanks for your information regarding DEFPARAM. This makes it much more easier than to amend the parameters within the code.

    How were the statistics in the test you made?

     

    DEFPARAM CumulateOrders = True
    //INDICATOR
    IBS = (Close-Low) / (HIGH-LOW) * 100
    RSI2 = RSI[2](close)
    MA = average[maperiod](close)
    
    //CONTRACTSIZE
    X = 1
    
    //MOVING AVERAGE PERIOD
    maperiod = 200
    
    //SIGNAL
    IBSLONGTRIGGER = 50
    IBSSHORTTRIGGER = 50
    
    RSILONGTRIGGER = 10
    RSILONGEXIT = 80
    RSISHORTTRIGGER = 90
    RSISHORTEXIT = 20
    
    //ENTRY CONDITION
    l1 = NOT LongOnMarket
    l1 = l1 and IBS > IBSLONGTRIGGER
    l1 = IBS[1] < IBSLONGTRIGGER[1]
    l1 = l1 and RSI2 > RSILONGTRIGGER
    l1 = RSI2[1] < RSILONGTRIGGER[1]
    l1 = l1 and low[1] > MA
    
    b1 = NOT ShortOnMarket
    b1 = b1 and IBS < IBSSHORTTRIGGER
    b1 = IBS[1] > IBSSHORTTRIGGER[1]
    b1 = b1 and RSI2 < RSISHORTTRIGGER
    b1 = RSI2[1] > RSISHORTTRIGGER[1]
    b1 = b1 and high [1] < MA
    
    //EXIT CONDITION
    l2 = LongOnMarket
    l2 = RSI2 > RSILONGEXIT
    
    b2 = ShortOnMarket
    b2 = RSI2 < RSISHORTEXIT
    
    //LONG ENTRY
    IF l1 THEN
    BUY X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    
    //LONG EXIT
    If l2 THEN
    SELL X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    
    //SHORT ENTRY
    IF b1 THEN
    SELLSHORT X CONTRACTS AT MARKET NextBarOpen
    ENDIF
    
    //SHORT EXIT
    IF b2 THEN
    EXITSHORT AT MARKET NextBarOpen
    ENDIF

     

    #53860 quote
    victormork
    Participant
    Veteran
    CumulateOrders = True? Should it not be set to false? You wanted 1 position only right?
    #53865 quote
    Marc
    Participant
    Average

    I play with several combination of parameters. Feel free to play with this and every parameter. 🙂

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

RSI and IBS based EA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marc @mast83 Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Marc
8 years, 3 months ago.

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