Over RSI for a set period

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

    In commodities like oil and gas the market loves to squeeze users who enter a short or long because RSI passes a certain threshold, because as an indicator it leads to many jumping the gun, while MACD is too much of a lag.

    Is there a way to code to not just measure RSI going above a level, but put an optimised condition of how long above that level it stays before entering a short or long. (Not the frequency it hits the level)

    #220430 quote
    JS
    Participant
    Veteran

    Hi,

    You can indeed introduce an extra condition to determine and optimize the number of bars above a certain level…

     
    DefParam CumulateOrders=False
    
    Once OBCount=0
    Once OSCount=0
    
    If RSI[20](Close)>70 then
    OBCount=OBCount+1
    EndIf
    
    If OBCount>xOB then
    SellShort 1 contract at Market
    OBCount=0
    EndIf
    
    If RSI[20](Close)<30 then
    OSCount=OSCount+1
    EndIf
    
    If OSCount>xOS then
    Buy 1 contract at Market
    OSCount=0
    EndIf
    Scherm­afbeelding-2023-09-06-om-16.15.44.png Scherm­afbeelding-2023-09-06-om-16.15.44.png Scherm­afbeelding-2023-09-06-om-16.16.08.png Scherm­afbeelding-2023-09-06-om-16.16.08.png Scherm­afbeelding-2023-09-06-om-16.16.40.png Scherm­afbeelding-2023-09-06-om-16.16.40.png
    #220434 quote
    robertogozzi
    Moderator
    Master
    This example will make sure that RSI has always been in OverBought in the last 10 bars:
    N      = 10
    myCond = (summation[N](rsi[14](close) > 70) = N)
    add myCond to your conditions to enter a trade.
    #220439 quote
    nightjimbob
    Participant
    New
    THanks both! Will give it a go
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Over RSI for a set period


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by nightjimbob
2 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/06/2023
Status: Active
Attachments: 3 files
Logo Logo
Loading...