Trailing Take Profit Linked to Equity

Forums ProRealTime English forum ProOrder support Trailing Take Profit Linked to Equity

Viewing 6 posts - 1 through 6 (of 6 total)
  • #237580

    Hello Team,

    I’m new to (PRT) and have been thoroughly enjoying learning and improving my skills on the platform.

    I’ve written a code for a strategy but would greatly appreciate your support and advice. My goal is to implement a trailing take profit that is tied to my equity, specifically based on the initial capital used to enter a position. However, as I am new to coding in PRT, I may have used incorrect keywords or syntax.

    What I am trying to achieve is to secure the gains made while in the market by establishing a trailing take profit system that locks in profits at specified increments (e.g., secure profits every $5,000). The idea is that as my profits increase, the trailing stop would adjust accordingly and ensure that profits are locked in and the position remains open. The position should only be exited when the profit falls below the trailing take profit level.

     

    Thank you for your assistance

    #237658

    Anyone can advise in this regards please

     

    Thank you

    #237665

    PositionPerf is NOT the current gains, it’s a multiplier to be applied to PositionPrice (the average opening price, same as the opening price when not accumulating positions),  so that PositionPrice * PositionPerf  is the base for the current gain (loss, if negative), but it must be additionally adjusted according to the value of each pip and to the size of the position, so that the complete formula is MyGain = PositionPrice * POSITIONPERF * PipValue * abs(CountOfPosition).

    This the amended code (I also changed several lines and got rid of some of them):

    Im not pretty sure it is exactly what you want, please test it and give me some feedback.

     

    1 user thanked author for this post.
    #237736

    Thanks Rbertogozzi for your feedback

    Kindly, I need some clarification before test it,  dose the (Pips = Trailingamount /PipValue/abs(CountOfPosition) work to ensure that profits are locked in and the position remains open?

    My idea is as long as the direction moving to my favor it secure the new profits and move to next trailing amount point. What I want is the position only be exited when the profit falls below the trailing take profit level which suppose to be updated each time profit increase by (5000$) .  The idea is similar to use dynamic take profit strategy but linked to amount of my equity instead of points or %.

     

    Correct me if I’m wrong please. I think should be  (Equity < Equitytrailing) in order to exit the position.

    Thanks a lot

    #237762

    Kindly, I need some clarification before test it, dose the (Pips = Trailingamount /PipValue/abs(CountOfPosition) work to ensure that profits are locked in and the position remains open?

    No, actually it converts the money into pips, because to me it seems to work better.

    Correct me if I’m wrong please. I think should be (Equity < Equitytrailing) in order to exit the position.

    When exactly do you want to exit?

     

     

    #237797

    Hi Rberto,

    The code is good so far but the result of testing the above code is , it give me a fixed target profit , while I intend to implement a dynamic one which secure the profit without exit the position and continue moving and exit the position only when profit drop below  trailing amount. In the current code the position exited through take profit when reach my trailing amount (after 250 points which is (20$ *250=5000$ in NASDAQ).

    I  tried to implement this code to get a dynamic take profit , but it doesn’t work well.

    // Trailing take profit
    IF ONMARKET Then
    Pips = Trailingamount / PipValue / abs(CountOfPosition)
    Equity = Capital + (PositionPrice * POSITIONPERF * PipValue * abs(CountOfPosition))
    if Equity – Pips > Pips THEN
    Equitytrailing = Equitytrailing + Pips
    ENDIF
    // Set target price based on trailing equity
    Set TARGET PRICE Equitytrailing
    ENDIF

    Any idea or enhancement?

     

    Thanks

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

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