Breakeven with a technical indicator

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #157735 quote
    Oliviertrader2020
    Participant
    Average

    Hello,
    Is it possible to put the SL in Breakeven when it reaches a technical indicator?

    Example :
    – I buy when the price bounces on the lower bollinger band
    – I place my SL under the most recent low
    – I target as TP the upper bollinger band

    Is it possible to move the SL to breakeven when the price reaches the SMA20?

    #157737 quote
    Vonasi
    Moderator
    Master

    You can place orders to sell at any price using pending STOP and LIMIT orders. So just check if your SMA condition has been met and then set a flag and send a pending order to sell at TRADEPRICE for every bar while the flag is true. Reset the flag once NOT ONMARKET.

    Nicolas and Oliviertrader2020 thanked this post
    #157963 quote
    Oliviertrader2020
    Participant
    Average

    Hello @vonasi, thank you, I tried to put a flag for the condition (close>=SMA20 ), in order to move the SL to breakeven.
    But I think there’s a mistake in my coding.
    Can you help me?

    
    // BUY
    if ConditionsPurchase AND Not OnMarket then
    BUY 1 lot AT market
    endif
    
    // BREAKEVEN
    SMA20 = Average [20](close)
    once flag = (close >= SMA20)
    if OnMarket AND flag =1 then
    SELL 1 lot AT TRADEPRICE +1 LIMIT
    endif
    
    // TP = HIGH BOLLINGER
    BBH = BollingerUp [20](close)
    C3 = (high >= BBH)
    
    MyConditionsCloture = C3
    
    if MyConditionsCloture AND OnMarket then
    SELL 1 lot AT market
    endif
    
    #157978 quote
    palettofix
    Participant
    Junior

    The “once” in line 8 is wrong. This calculation is done once at the start, not on every candle. Just remove it.

    Oliviertrader2020 thanked this post
    #157986 quote
    Vonasi
    Moderator
    Master

    LIMIT sells at a better price than the current close whereas STOP sells at an inferior price than the current close so you are using the wrong instruction.

    Also as said before ONCE is not neeeded.

    Oliviertrader2020 thanked this post
    #158012 quote
    Oliviertrader2020
    Participant
    Average

    @ thank you very much 🙂

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

Breakeven with a technical indicator


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by Oliviertrader2020
5 years, 1 month ago.

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