Breakeven stop with RSI control

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #182792 quote
    phoentzsphoentzs
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    phoentzsphoentzs
    Participant
    Master

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

    But in percent?

    #182805 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    phoentzsphoentzs
    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.
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

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 phoentzsphoentzs
4 years, 10 months ago.

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