RSI IBS in Variation – Problem with SL

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #83867 quote
    Marc
    Participant
    Average

    Hi together,
    pls find attached code.
    For some reasons I want to have a secure SL

    When system is long this SL should trigger when MA10 < MA200
    When system is short this SL should trigger when MA10 > MA200

    SL for Long is called SLL, SL for short is called SLS.

    I think there is an issue with this EA…can somebody confirm if this coding is correct or not and help me to amend it?

     

    DEFPARAM CUMULATEORDERS = false
    REM Money Management
    //Capital = 10000
    //Risk = 0.001  // Faktor für Kontraktgröße
    //StopLoss = 10 // StoppLoss
     
    REM Calculate contracts
    //equity = Capital + StrategyProfit
    //maxrisk = round(equity*Risk)
    //x = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    x = 1
    
    //Indikatoren
    MM200 = average[200](close)
    MM10 = average[10](close)
    RSI2 =RSI[2]((close+high+low)/3)
    IBS = (Close-Low) / (High-Low) * 100
    
    //STOP LOSS SIGNAL
    //SLL = MM10 < MM200
    //SLS = MM10 > MM200
    
    //LONG
    ca1 = close > MM200 AND MM200[1] < MM200[0]
    ca2 = RSI2 < a                 //DAX 9, BUND 6, S&P 8, EURUSD 10, Gold 6, WTI 10
    ca3 = IBS < b                  //DAX 9, BUND 10, S&P 8, EURUSD 8, Gold 10, WTI 10
    
    IF NOT LONGONMARKET AND ca1 and ca2 and ca3 THEN
    BUY x CONTRACT at market NEXTBAROPEN
    ENDIF
    
    //EXIT LONG
    IF LONGONMARKET AND close > MM10 THEN
    sell at market NEXTBAROPEN
    //SET STOP LOSS SLL
    ENDIF
    
    //SHORT
    cv1 = close < MM200 AND MM200[1] > MM200 [0]
    cv2 = RSI2 > c                  //DAX 95, BUND 90, S&P 97, EURUSD 90, Gold 95, WTI 95
    cv3 = IBS > d                   //DAX 90, BUND 98, S&P 90, EURUSD 92, Gold 93, WTI 90
    
    IF NOT SHORTONMARKET AND cv1 and cv2 and cv3 THEN
    SELLSHORT x CONTRACT at market NEXTBAROPEN
    ENDIF
    
    //EXIT SHORT
    IF SHORTONMARKET AND close < MM10 THEN
    exitshort at market NEXTBAROPEN
    //SET STOP LOSS SLS
    ENDIF
    #83876 quote
    robertogozzi
    Moderator
    Master

    Add these lines (or more if you need) at the end of your code to check the value retained by those variables each bar, as from the screenshot. This will help you discover errors:

    graph MM10
    graph MM200
    graph close
    x-8.jpg x-8.jpg
    #83885 quote
    GraHal
    Participant
    Master

    I’ve tried a few things but I can’t get your code to execute a Short trade.

    I’m sure there is a simple explanation. I’ll probably try again later! 🙂

    #83887 quote
    GraHal
    Participant
    Master

    Sorted … I get Short trades now … I was testing on too low / short a timeframe!

    #83939 quote
    Marc
    Participant
    Average

    Thank you very much for your help…I think it works now…check out screenshot attached…not many trades, but they seem to be okay

    DAX_RSIIBS.jpg DAX_RSIIBS.jpg
    #83943 quote
    Marc
    Participant
    Average

    Now I see it is not working as it should be… SL for long and short doesn’t work -.-

    Graph shows this

    #83951 quote
    Nicolas
    Keymaster
    Master

    What you call the “SL” are coded at lines 34 and 49. The orders should be exited when Close is above or below the 10 periods moving average, why do you think it is not working?

    #83965 quote
    Marc
    Participant
    Average

    I understand. I want to have sth like an emergency Stop: line 35 and 50.

    Do I have to implement this to snippets after line 29 and 44?

    #83966 quote
    Marc
    Participant
    Average

    Backtest S&P500

    SP500_RSIIBS.jpg SP500_RSIIBS.jpg
    #83968 quote
    Marc
    Participant
    Average

    Test: Nasdaq

    NASDAQ_RSIIBS.jpg NASDAQ_RSIIBS.jpg
    #83970 quote
    Marc
    Participant
    Average
    #83972 quote
    Marc
    Participant
    Average

    TEST EURO-BUND

    BUND_RSIIBS.jpg BUND_RSIIBS.jpg
    #83974 quote
    Marc
    Participant
    Average
    #83976 quote
    Marc
    Participant
    Average
    #84039 quote
    Marc
    Participant
    Average

    One additional question…

    How can I instert the feature to  type in externaml parameters?

    Pls see Screenshot below.

    When playcing RSI I am able to change oversold and overbought zones within the code…I tried to add this feature to IBS…but it doesn’t work without changin paraemters in all other chartwindows

    external-parameter.jpg external-parameter.jpg
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.

RSI IBS in Variation – Problem with SL


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marc @mast83 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/31/2018
Status: Active
Attachments: 9 files
Logo Logo
Loading...