Noob coding advice RSI stop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #186725 quote
    bob320bob320
    Participant
    New

    Hi Team,

    Please be gentle with me, Im a complete noob and Im pretty sure my questions may be daft and basic. Anyway I`ve created a simple RSI strategy using the Simplified creation builder and applied it to the FTSE100 at 20min timeframe, on back-testing, it seems to turn a profit most of the time

    However, back-testing further, there are certain dates like Feb / March 2020 where the market took a severe nose dive or October 2020 where there was a sharp upturn and I was wrong side and get stopped out. Is there a way I can prevent it from opening positions when the market is moving in one direction or another sharply?

    Sorry if I sound like a complete noob.

    Code looks like this, thanks in advance:

    ===================================================

     

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = RSI[17](close)
    c1 = (indicator1 CROSSES OVER 29)

    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit long positions
    indicator2 = RSI[17](close)
    c2 = (indicator2 CROSSES OVER 70)

    IF c2 THEN
    SELL AT MARKET
    ENDIF

    // Conditions to enter short positions
    indicator3 = RSI[17](close)
    c3 = (indicator3 CROSSES UNDER 70)

    IF c3 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit short positions
    indicator4 = RSI[17](close)
    c4 = (indicator4 CROSSES UNDER 29)

    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF

    #186753 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Yes, you can add two variables to enable, or disable, opening Long or Short trades by setting them to either 1 or 0. I named them GoLong and GoShort:

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    GoLong  = 1      //0=disabled, 1=enabled
    GoShort = 1      //0=disabled, 1=enabled
    
    // Conditions to enter long positions
    indicator1 = RSI[17](close)
    c1 = (indicator1 CROSSES OVER 29)
    
    IF c1 and GoLong THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = RSI[17](close)
    c2 = (indicator2 CROSSES OVER 70)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = RSI[17](close)
    c3 = (indicator3 CROSSES UNDER 70)
    
    IF c3 and GoShort THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator4 = RSI[17](close)
    c4 = (indicator4 CROSSES UNDER 29)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    bob320 thanked this post
    #186773 quote
    nonethelessnonetheless
    Participant
    Master

    I may be completely wrong, but I think what he’s looking for is more of  a trend detection – another condition that will prevent his trade opening in the wrong direction, or will cut out if the trend moves sharply against him ???

    for example

    Timeframe (1 hour) 
    ma = average[a,t](typicalprice)
    cb1 = ma > ma[1] 
    cs1 = ma < ma[1]
    robertogozzi and bob320 thanked this post
    #186859 quote
    bob320bob320
    Participant
    New

    Hi Guys,

    Thank you so much for you time and responses, much appreciated. I understand I can use additional indicators to determine if I should open a position, I guess I`m wondering what specific indicators and values would prevent opening the trades on the dates where the markets fell or rose in a big way.

    Maybe some code that says if the market has shifted +/- 2% since open, don`t trade?

    Thanks Again

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Noob coding advice RSI stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
bob320 @bob320 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/27/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...