SetPercentTrailing: Difference between revisions
From MultiCharts
No edit summary |
|||
Line 1: | Line 1: | ||
Closes out the entire position or the entry if the specified percentage of the maximum profit is lost after the profit has reached the specified value; generates the appropriate Stop order depending on whether the position is | Closes out the entire position or the entry if the specified percentage of the maximum profit is lost after the profit has reached the specified value; generates the appropriate [[Stop]] order depending on whether the position is [[Long]] or [[Short]]. | ||
For example, if the specified profit is $100 and the specified percentage is 50, and the profit has reached the maximum of $120, the position will be closed once the profit falls back to $60. | For example, if the specified profit is $100 and the specified percentage is 50, and the profit has reached the maximum of $120, the position will be closed once the profit falls back to $60. | ||
[[SetStopPosition]] and [[SetStopContract]] or [[SetStopShare]] functions determine whether SetPercentTrailing will be applied to the entire position or each contract or share individually; by default, SetPercentTrailing is applied to the entire position. | [[SetStopPosition]] and [[SetStopContract]] or [[SetStopShare]] functions determine whether '''SetPercentTrailing''' will be applied to the entire position or each contract or share individually; by default, '''SetPercentTrailing''' is applied to the entire position. | ||
SetPercentTrailing function is evaluated intra-bar and not only on close of a bar, and can exit within the same bar as the entry. | <div style="background-color: #C1FFC1;margin-bottom:10px;">The SetPercentTrailing function is evaluated intra-bar and not only on close of a bar, and can exit within the same bar as the entry.</div> | ||
== Usage == | |||
<syntaxhighlight>SetPercentTrailing(Profit,Percentage)</syntaxhighlight> | <syntaxhighlight>SetPercentTrailing(Profit, Percentage)</syntaxhighlight> | ||
Where: | Where: | ||
:'''Profit''' - a numerical expression, specifying the currency value of the profit that must be reached first. | |||
:'''Percentage''' - a numerical expression, specifying the maximum loss of profit in percent. | |||
== Notes == | |||
This function can only be used in signals. | * This function can only be used in signals. | ||
* Use [[SetStopLoss]] to set a stop-loss for a position or [[SetProfitTarget]] to set a profit target. | |||
* Use [[SetDollarTrailing]] for a fixed-amount currency trailing stop. | |||
== | == Examples == | ||
Generate an exit order for the entire position if 50 percent of maximum position profit is lost | Generate an exit order for the entire position if 50 percent of maximum position profit is lost after the profit has reached $25: | ||
after the profit has reached $25: | |||
<syntaxhighlight>SetStopPosition; | <syntaxhighlight>SetStopPosition; | ||
SetPercentTrailing(25,50);</syntaxhighlight> | SetPercentTrailing(25, 50);</syntaxhighlight> | ||
Generate an exit order for the entry if 25 percent of maximum per share profit is lost after the | Generate an exit order for the entry if 25 percent of maximum per share profit is lost after the profit has reached $5: | ||
profit has reached $5: | |||
<syntaxhighlight>SetStopShare; | <syntaxhighlight>SetStopShare; | ||
SetPercentTrailing(5,25);</syntaxhighlight> | SetPercentTrailing(5, 25);</syntaxhighlight> | ||
[[Category:Strategy Orders]] | [[Category:Strategy Orders]] |