Setting up Stop Loss and Take Profit with defined Risk Reward

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #170127 quote
    ledererlederer
    Participant
    New

    Hello need some help with coding, too dumb for this….

    – after entering a long/short position, the stop is placed for a long position (1 candles back low) and for short (1 candles back high)

    – after setting up stop loss, it should set the take profit with an risk reward ratio of 1:1.5 for future candles

    For example:

    Long/short condition requirements are met then set stop loss 1 candle back at low and set take profit by risk reward ratio 1:1.5

    • example #1 long -> entry price is 100 -> lowest price on last candle is 90, set stop loss there -> set from there target profit with RR of 1.5 which would be 15 at price of 115
    • example #2 short -> entry price 100 -> highes price on last candle is 110, set stop loss there -> set target profit at with rr of 1.5 which would be 15  at price of 85

    something like that…..

    IF MyLongConditions AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       NewSL = low[1]
       SELL  AT NewSL STOP
       SET TARGET $PROFIT((tradeprice(0) - NewSL)*1.5)
    ENDIF
    //
    IF MyShortConditions AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
       NewSL = high[1]
       EXITSHORT AT NewSL STOP
       SET TARGET $PROFIT((NewSL - tradeprice(0))*1.5)
    ENDIF
    #170255 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    IF MyLongConditions AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       SL = abs(close - low[1])
       TP = SL * 1.5
       SET TARGET PROFIT TP
       SET STOP   LOSS   SL
    ENDIF
    //
    IF MyShortConditions AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SL = abs(close - high[1])
       SET TARGET PROFIT TP
       SET STOP   LOSS   SL
    ENDIF

    it’s better to use SET TARGET PROFIT and SET STOP LOSS whenever possible, because pending orders expire each bar and need to be placed again till the trade is closed.

    lederer thanked this post
    #170261 quote
    ledererlederer
    Participant
    New

    Thank you very much Roberto, works as intended, but my strategy needs more refinements.

Viewing 3 posts - 1 through 3 (of 3 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

Setting up Stop Loss and Take Profit with defined Risk Reward


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
lederer @lederer Participant
Summary

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

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