Breakeven stop with RSI control

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #182792 quote
    phoentzs
    Participant
    Master

    Hello, is it possible to combine a breakeven stop with an RSI value? If the price is above / below the purchase price and the RSI12 closes above / below 70/30, the stop should be drawn to breakeven. In %. Could someone code that, please?

    #182802 quote
    robertogozzi
    Moderator
    Master

    There you go:

    IF Not OnMarket THEN
        ExitrPrice = 0
    ENDIF
    MyRSI = Rsi[12](close)
    IF (LongOnMarket AND close > PositionPrice  AND MyRSI > 70) OR (ShortOnMarket AND close < PositionPrice  AND MyRSI < 30) THEN
       ExitPrice = PositionPrice
    ENDIF
    IF ExitPrice THEN
       SELL      AT ExitPrice STOP
       EXITSHORT AT ExitPrice STOP
    ENDIF

    I can’t understand what you mean by “in %“. Breakeven is the entry price.

    #182803 quote
    phoentzs
    Participant
    Master

    Ah, my mistake. Then I said, for example: Breakeven + 5 * Pipsize

    But in percent?

    #182805 quote
    robertogozzi
    Moderator
    Master

    Ok, there you go:

    PointsToKeep = 5 * PipSize     //save 5 pips beyond breakeven
    IF Not OnMarket THEN
        ExitPrice = 0
    ENDIF
    MyRSI = Rsi[12](close)
    IF LongOnMarket AND close > PositionPrice AND MyRSI > 70 THEN
       ExitPrice = PositionPrice + PointsToKeep
    ELSIF ShortOnMarket AND close < PositionPrice AND MyRSI < 30 THEN
       ExitPrice = PositionPrice - PointsToKeep
    ENDIF
    IF ExitPrice THEN
       SELL      AT ExitPrice STOP
       EXITSHORT AT ExitPrice STOP
    ENDIF
    Midlanddave and thanked this post
    #182806 quote
    robertogozzi
    Moderator
    Master

    If you want to use a %, you can replace the first line with the following:

    MyFormula    = PositionPrice           //or Range, or abs(close - PositionPrice), etc...
    PointsToKeep = MyFormula / 100 * 0.05  //0.05%

    you can use any formula of your choice in line 1.

    Midlanddave thanked this post
    #182810 quote
    phoentzs
    Participant
    Master

    Thanks Roberto, you are the best.

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

Breakeven stop with RSI control


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by phoentzs
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/03/2021
Status: Active
Attachments: No files
Logo Logo
Loading...