ATRTrailingStop values in watchlist adapted to Bonds


Category:
0
0

Hi Pete!

This question is a refinement of a previous question:   https://www.hahn-tech.com/ans/display-atrtrailing-stop-values-in-a-watchlist/

I trade bonds (UB ZB ZN ZF). When I put ATRTrailingstop in a watchlist for these products, TOS is displaying the price like this: “106.1203744” instead of like this: “107’270”.

For the same products, TOS displays the “Last” value in the watchlist as 107’270 (which I am referring to here as “normal”).

Is it possible to have the watchlist values adapt to specific financial instruments such as bond futures?  I want the ATRts values to display in the watchlist like this “107’270” rather than like this “106.1203744”

Screenshot is attached containing an image of the entire watchlist.

Sorry I could not be more specific in the Question Title.  I did the best I could using the max allowance of 50 characters.  Please feel free to change anything about my post to make it correct.

Attachments:
Marked as spam
Posted by (Questions: 7, Answers: 1)
Asked on November 17, 2022 12:03 pm
61 views
0
Private answer

This does require a custom solution since the built-in column for the ATRTrailingStop does not adapt to instruments which are still quoted in fractions.

This solution will adapt to stocks, futures and bonds. However it will not Forex pairs. So I have included a user input to round the number of decimals. The default value is 2 and for any Forex symbols you will need to increase that value accordingly. This is the most advanced solution I can provide in the time I allocated to free solutions I provide in this forum.

input decimalsToRound = 2;
input trailType = {default modified, unmodified};
input atrPeriod = 5;
input atrFactor = 3.5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
def trailStop = ATRTrailingStop(trailType, atrPeriod, atrFactor, firstTrade, averageType).TrailingStop;
AddLabel(yes, AsPrice(Round(trailStop, decimalsToRound)), if trailStop > close then Color.RED else Color.GREEN);

FYI, When we use the "AddLabel()" statement to display values in a watchlist column, that column can not longer be used to sort by those values.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 17, 2022 1:16 pm