Login Page - Create Account

Support Board


Date/Time: Sat, 15 May 2021 11:44:02 +0000



[Programming Help] - Study to manage position with breakeven and trailstop/target

[2021-04-03 18:29:58]
AlexPereira - Posts: 193 | Ending Date: 2020-04-26 [Expired]
Hi,

so as mentioned here: https://www.sierrachart.com/SupportBoard.php?ThreadID=62945#P260490 , I am posting this study for Sierrachart that I use to manage positions with a adjustable breakeven and trailstop/target.

The study creates 3 drawings/subgrapths:
* Breakeven
* Trailtarget
* Trailstop.

Breakeven is kinda explanatory ( one detail, only is activated if stop is further away than configured offset. Also it only moves stop if it has at least an "offset" distance from where the stop will be put. ex: if offset is 4, even if breakeven line is reached, it will only move stop when there is at least 4 ticks difference from where stop will be put )

"Tailtarget" is the price that when touched, will move the stop into the "trailstop". When this happens, it will then increase ( or decrease depending on the direction of the trade ) the trailtarget and trailstop with the offset.

Also, if the position limit/target is within the offset, it will move the position limit/target further away.

This study needs a position with a stop and a target ( haven't used it with multiple targets/stops ). The breakeven and trailstop/target are configured through a percentage based between position stop and target ( it was used mainly for a strategy with fibonacci ratios.

Also, to adjust the breakeven and trailstop/targets, it has to be by keyboard shortcuts. Currently its hardcoded to listen to ACS_BUTTON_21 (breakeven) , ACS_BUTTON_22 (trailstop) and ACS_BUTTON_23 (trailtarget). Just set the mouse pointer in the chart on the price you wish to set and press the keyboard shortcut.
( documentation about setting these shortcuts: https://www.sierrachart.com/index.php?page=doc/ACSInteractionWithMenusControlBarButtonsPointerEvents.php#ACSControlBarButtonKeyboardShortcuts )


Disclaimer: I am just a programmer, so please don't use this on live accounts until you tested it in all your conditions. I used this together with a trading system based on swings and fibonacci ratios. But your usage may be very different than mine and it might not work the way you want it.
Also i am just uploading the dll, but if anyone really wants to use this, I don't mind posting the source code ( although I will have to look at what is currently being done in terms of licensing for posting SC studies source code )

Documentation of study parameters:

* Real:1/Simulation trading:0 -> if using the study live, set this to 1. If in simulation, set this to 0. always keep it in 0 unless you really tested it in your conditions.
* Auto Trail ON -> enable auto trail. if disabled (0), it will just do breakeven.
* Study Enabled -> if the study will do anything. if 0, the study will be disabled and not do anything.
* Trail Offset in ticks -> offset in ticks which will be the ticks to increase when trailing target reached and number of ticks offset of breakeven ( breakeven stop will be placed in position + this offset in ticks )
* Breakeven Style/Trail Target Style/Trail Stop Style -> the style of the graphs. configure it how you would do any other graph.
* Trail Target Ratio Fib -> The percentage where to place the trail target by default. the calculation will be the percentage from the position target into the position stop ( for example, draw a fib from the position target to position stop ).
* Trail Stop Ratio Fib -> Same as above but for the trail stop.
* Breakeven Ratio Fib -> Same as above but for breakeven.
* External ATR Study -> if you have an ATR study, you can point to that study and it will autoset the "Trail Offset in ticks" with its value.
* ATR Multiplier -> In case of setting the "Trail Offset in ticks" automatically, use this to apply a multiplier to that value. ( ex: atr is 10, if this field is 2, the offset is gonna be 20 )
* USE External ATR Study for ATR Offset -> 1 to enable the usage of the external ATR study. If 0, it will try to read the atr in a file in Sierrachart Data/conf/"NAME OF CHARTBOOK"/atr.conf
* Ticksize Multiplier -> multiplier for ticksize, mainly set this to 1, unless analysing a instrument and trading in another with a different tick size.

Hope it helps.
attachmentajp_study_position_64.dll - Attached On 2021-04-03 18:28:41 UTC - Size: 969.5 KB - 32 views
Attachment Deleted.

To post a message in this thread, you need to login with your Sierra Chart account:

Login

Login Page - Create Account