trailing stops to all positions after they hit a combined profit?

Forums ProRealTime English forum ProOrder support trailing stops to all positions after they hit a combined profit?

This topic contains 6 replies, has 3 voices, and was last updated by avatar bartjawien 1 year ago.

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • #96661

    Hey guys. I’m keen to understand how to reset or add new trailing stops to all positions that are running after they hit a combined profit margin. Here is a some code in working with;

    Will the Set Stop apply a $500 Trailing Stop all positions?

    #96742

    No. Because the stop will only be in place when FloatingProfit equals 3500 exactly. A very rare thing I imagine. You need to set a flag when price >= 3500 and then only have the trailing stop in operation if that flag is set. Otherwise the trailing stop only works if price goes from >= all the way down to your stop price in one bar.  Reset the flag to zero if price falls below your stop level.

    #97056

    Thanks @vonasi,

    Here’s a real snippet I’m testing at the moment across a few pairs and it seems to work sometimes and not others – what am I getting wrong?

    I’ve been monitoring it on the AUD/USD and it triggered fine. However, miss fires on the USD/CAD. Could it not be converting to the AUD for the total gain for all running positions? I’m expecting the FloatingProfit to be calculated in AUD for all open position for that individual system …

    Keen to hear your thoughts guys.

    #97057

    The pointvalue instruction, use to calculate the floating profit, is in the currency of the current instrument, not in the currency of your account, because there is no way to get it through code. You’ll have to make a conversion yourself in the code for that.

    #97061

    Thanks again,

    So the code looks correct?

    The instrument I’ve been testing on is the USD/CAD where the system calculates the gain for open positions in CAD. Do you mean I’ll have to code a conversation back into AUD which what I believe you’re saying?

    As for the terminology for the system ‘latent gain’ and ‘today gain’ I’m not looking to calculate the total latent gain for the system for all time.

    All I’m looking to test is:

    My system opens short and long position, and if the combined open and running positions hit a certain value a trailing stop is activated for all running positions. If the positions are then stopped-out because the market reversed — next time the system opens a new set of positions the floatingprofit will start from zero.

    Apologies if I’m not explaining myself properly.

    Thoughts?

     

    #98409

    Hey @nicolas – I’ve been testing the above and recently found a flaw in my code;

    One of these functions is calculating the total gain value for the system rather than only the current open positions;

    (close-positionprice)*pointvalue)*countofposition)/pipsize

    The solution or advice I’m looking for is to find a way to reset the floatingprofit at each new position open. Is there a function to do this?

     

    Would this work … subtracting the system profit using strategyprofit function from the total accumalative floatingprofit:

    FloatingProfit = Strategyprofit – (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual open trade gains

     

    Thanks in advance.

    Bart

    #98410

    Sorry –

    Would this work … subtracting the system profit using strategyprofit function from the total accumalative floatingprofit:

    FloatingProfit = Strategyprofit – (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual open trade gains

    Sorry – should be the otherway around;

    FloatingProfit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize) – Strategyprofit //actual open trade gains

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

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