Never two or more time trading in same direction

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #7069 quote
    Bolu14
    Participant
    New

    Hello,

    i try to create a code for the following Trading Idea:

    Enter Long:

    RSI undercross 30 and the last trade have to be a short Trade

    Enter Short

    RSI overcross 70 and the last trade have to be a long Trade

    Exit only with StopLoss or Positionchange (maybe from long to short or short to long)

    My Intention is, that in Case of a Strong Trend the RSI will generate may times short signals (maybe on a UpTrend). RSI will swing at the 70 Line and create many failure Signals. If the Short signal is given, then the next trading should be a Long Trade, means that i trade only one time the Short Signal. And if the RSI Swing at 70 and create manytimes short Signals, these does not matter to me. I will wait, until a long Signal is coming.

    I hope you understand.

    I use this on Dax 1 Minute Timeframe. In Strong Trends it generates 6-10 times failuresignal behind each other. I want to decrese that.

    So, that is my code, which i create, but i can`t  build the condition with the direction of the last trade.

    // Code-Parameter
    DEFPARAM CumulateOrders = False 
    DEFPARAM Flatbefore = 090500
    DEFPARAM Flatafter = 215500
    
    // Enter Long Position
    indicator1 = RSI[14]
    c1 = (indicator1 CROSSES UNDER 30)
    c7 = ShortOnMarket[1] = 1
    
    IF c1 AND c7 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Exit Long Position
    indicator2 = RSI[14]
    c2 = (indicator2 >= 65)
    
    c3 = (close <= open[1])
    
    IF c3 AND c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Enter Short Position
    indicator3 = RSI[14]
    c4 = (indicator3 CROSSES OVER 70)
    c8 = LongOnMarket[1] = 1
    
    IF c4 AND c8 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Exit Short Position
    c5 = (close >= open[1])
    
    indicator4 = RSI[14]
    c6 = (indicator4 <= 35)
    
    IF c5 AND c6 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // MoneyManagement
    SET STOP pLOSS 14

    I dont know,  how i can check, in which the  last trade was going on. Was it a Longtrade or Shorttrade ?

    I hope you can help me.

    Thanks

    Test-Alpha-V0.1.itf
    #7072 quote
    Bolu14
    Participant
    New

    In Line 9 and 28 i try to create the condition about the last trade, but i think this is wrong.

    #7088 quote
    Nicolas
    Keymaster
    Master

    Yes lines 9 and 28 are wrong, nice try 🙂

    So if I understand you correctly, you want to launch a buy trade only if the last one was a sell? and so on for a sell if the last one was a buy?

    #7090 quote
    Bolu14
    Participant
    New

    Yes. Because in Case of a LongTrend maybe, this system generates many FailureSignals, all short Signals (at LongTrend), and i dont want to trade this until the Dax is normal (no Trend) and the RSI goes down to create a Long Signal.

    Now i Modify this, but in this case i dont get a trade. If i set manual the Variable on Line 7 to 1 then it runs, but this means, that i will start everyday with a short signal. It should be so, that the first Trade each day without this condition (Previous Long or Previous Short)

    Please Check this:

    // Code-Parameter
    DEFPARAM CumulateOrders = False
    DEFPARAM Flatbefore = 090500
    DEFPARAM Flatafter = 215500
    
    If Time = 090000 then
    PositionRichtung = 0
    EndIF
    
    
    // Enter Long Position
    indicator1 = RSI[14]
    c1 = (indicator1 CROSSES UNDER 30)
    c7 = (PositionRichtung < 0)
    
    If ShortOnMarket = 1 THEN
    PositionRichtung = -1
    EndIF
    
    IF c1 AND c7 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Exit Long Position
    indicator2 = RSI[14]
    c2 = (indicator2 >= 65)
    
    c3 = (close <= open[1])
    
    IF c3 AND c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Enter Short Position
    indicator3 = RSI[14]
    c4 = (indicator3 CROSSES OVER 70)
    c8 = (PositionRichtung > 0)
    
    If LongOnMarket = 1 THEN
    PositionRichtung = 1
    EndIF
    
    IF c4 AND c8 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Exit Short Position
    c5 = (close >= open[1])
    
    indicator4 = RSI[14]
    c6 = (indicator4 <= 35)
    
    IF c5 AND c6 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // MoneyManagement
    SET STOP pLOSS 14
    

     

    I try for long time, but i thinks this is near to my Final 🙂

    Test-Alpha-V0.2.itf
    #7093 quote
    Bolu14
    Participant
    New

    Here is a Screenshot, with failure Trades (short Entry) which i would not have, if it runs like i describe 🙂

    Deutschland-30-Kassa-1EUR-Mini-Kont-.png Deutschland-30-Kassa-1EUR-Mini-Kont-.png
    #7120 quote
    Nicolas
    Keymaster
    Master

    Ok, so it needs to flag a variable when a buy trading occur and another one when a sell trading occur. Then just test this variable to open a new position.

    This variable needs to be reset each new day at very first intraday bar.

    Here is your modified code: (haven’t test it)

    // Code-Parameter
    DEFPARAM CumulateOrders = False
    DEFPARAM Flatbefore = 090500
    DEFPARAM Flatafter = 215500
    
    If intradaybarindex=0 then
     PositionRichtung = 0
    EndIF
    
    
    // Enter Long Position
    indicator1 = RSI[14]
    c1 = (indicator1 CROSSES UNDER 30)
    c7 = (PositionRichtung < 0)
    
    IF c1 AND c7 and PositionRichtung <>1 THEN
    BUY 1 CONTRACT AT MARKET
    PositionRichtung = 1
    ENDIF
    
    // Exit Long Position
    indicator2 = RSI[14]
    c2 = (indicator2 >= 65)
    
    c3 = (close <= open[1])
    
    IF c3 AND c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Enter Short Position
    indicator3 = RSI[14]
    c4 = (indicator3 CROSSES OVER 70)
    c8 = (PositionRichtung > 0)
    
    IF c4 AND c8 and PositionRichtung <>-1 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    PositionRichtung = -1
    ENDIF
    
    // Exit Short Position
    c5 = (close >= open[1])
    
    indicator4 = RSI[14]
    c6 = (indicator4 <= 35)
    
    IF c5 AND c6 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // MoneyManagement
    SET STOP pLOSS 14
    #7140 quote
    Bolu14
    Participant
    New

    Thanks, it looks good.

    But the lines 14 and 34 have to be remove, because they are not needed anymore. Also the conditions “and c7” and “and c8” in Line 16 and 36. Then it runs.

    I try to reduce the failure Trades but the Problem is, that i lost the important trades too. These, where i can win 40-60 Points at the end of the Trend. With this System, i would ignore the last signals in the trend, these, where the Index will turn around.

    I hope you understand.

    Thanks for your support.

    #7154 quote
    Nicolas
    Keymaster
    Master

    Oh yes you are right about the c7 and c8 conditions, I forgot to remove them.

    About the false signals, you are trying to catch trend with a bounded oscillator on the last 14 period. Maybe you should look at price behaviour as a complement to the RSI.

    #8197 quote
    Bolu14
    Participant
    New

    Hello Nicolas,

    thanks for your support.

    I still run this “system” live on my account, but i see, that every morning the first trade are missing.

    I mean, that there should be a trade at maybe 09:13 but this first signal will not trade. It starts with the secound one.

    Where can be the problem?

    It is possible, that Intradaybarindex does not run because we have a condition like

    DEFPARAM Flatbefore = 090500

    At which time the intradaybarindex is = 0 ?

    The last version of this Code, i attach to this post.

    Thanks.

    Live-Alpha-V-1.0.itf
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Never two or more time trading in same direction


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bolu14 @bolu14 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/14/2016
Status: Active
Attachments: No files
Logo Logo
Loading...