RSI CODE help!

Viewing 8 posts - 1 through 8 (of 8 total)
  • #126779

    Hi Everyone,

    Hoping someone can help me.

    I am new to this and have written a simple code which opens a sell order when the RSI is >70 and a buy order at <30. I have included for a target point range, which for this example can be 5.

    The code works fine, except, when it opens a long/short and the market moves in the required direction taking the RSI below 70 or above 30 but does not however trigger the target of 5  but instead renters the >70 or <30 area, the program gets confused and will ignore the target of 5 and then only closes the short or long at the point of <30 and long at >70. Is there a change I can make that will ensure that any opened position will close at the target value irrespective if the value goes above or below the 30/70 RSI level, and also if this were to occur then every time it does break the RSI level, it opens a subsequent position. When I back test it as it is, its doing what I want except the times where it bounces in and out of the 70/30 area.

    Any advice, help or modifications to the code would be appreciated.

     

    #126803

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

    #126810

    Try increasing the your TP, 5 seems to not abide by the minimum distance required.

    10+ might solve it.

    #126884

    I don’t think that makes any difference, whilst backtesting and having found this issue, the problem isn’t with the TP its when the price drops below/above the 70/30 RSi and then revisits that area. at that point, I want the code to open another trade or if nothing else, just close out the original trade at the required TP. what actually happens is that it doesn’t do this and waits for it to open/close a trade at the opposite RSI. logically, it should close at the required TP, for whatever reason this does work, but fails if it renters the are of  70/30.

    #126897

    I can’t understand lines 2 and 3, They might be confusing.

    Line 2 is useless, since there cannot be anything  before 000000, -1 does not exist.

    Line 3 means at anytime because whatever the time it will be >  0.

    Your trades shouldn’t open at all, but if they do they should be immediately closed.

    #126906

    They do open.

    In any case, the issue I have is not with times as I can change them to suit.

     

    just trying to find a solution to the real problem, it’s not the TP.

    #126914

    You have to tell me:

    • instrument used
    • TF used
    • date & time of (some) candles where the strategy did not what expected.

     

    #126915

    Anyway, you can replace lines 7-8 with:

    this should do.

Viewing 8 posts - 1 through 8 (of 8 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login