Closing a position with SetPercentTrailing but at a limit price

Questions about MultiCharts and user contributed studies.
kinginhk
Posts: 10
Joined: 14 Jul 2022
Has thanked: 3 times

Closing a position with SetPercentTrailing but at a limit price

Postby kinginhk » 24 Nov 2022

hello all!

Thanks in advance for all the help.

I have this code in my signal (for a forex algo):

SetStopContract ;
SetPercentTrailing( X, Y) ;

X is the profit per contract, while Y is the trailing %.
Everything works fine, however i just noticed that during live trading, my position is closed consistently a few pips away from what my backtest indicates.
I speculate that it all drills down to SetPercentTrailing trading at market to exit this profitable trade, but since i'm aiming to make quick profits only, those few pips would eat up half of my expected gains alredy.

Is there any function or way I could recreate exactly what SetPercentTrailing does but making sure the exit trade is at a limit price to ensure my live trades trading prices match with the backtests?

I can't find a way to code my own SetPercentTrailing as the algo has many entry trades, i don't know how to track each trade independently.

Many thanks!

kinginhk
Posts: 10
Joined: 14 Jul 2022
Has thanked: 3 times

Re: Closing a position with SetPercentTrailing but at a limit price

Postby kinginhk » 29 Nov 2022

alternatively, can anyone help with an idea on how to track each entry trade, its P&L and also how to input a close order at limit price for a particular entry trade please? thanks!

the multiple entry trades are from the same entry signal (entry condition).

User avatar
Polly MultiCharts
Posts: 203
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 56 times

Re: Closing a position with SetPercentTrailing but at a limit price

Postby Polly MultiCharts » 30 Nov 2022

Hello kinginhk,

In auto trading if the specified percentage of the maximum profit is lost after the profit has reached the specified value, SetPercentTrailing generates the Stop Order depending on whether the position is Long or Short. Stop Orders might lead to slippage you’ve mentioned.
Unfortunately, there is no option to set Stop Limit Order instead of Stop Order in auto trading.
But you could post your idea at our Project Management and if it is popular among our users, our developers will review the possibility of adding it.


Return to “MultiCharts”