Need some guidance with the ATR Trailing LX(SX) signal of MC

Questions about MultiCharts and user contributed studies.
my2108
Posts: 12
Joined: 06 Aug 2018
Has thanked: 1 time

Need some guidance with the ATR Trailing LX(SX) signal of MC

Postby my2108 » 28 Oct 2018

HI all,
I get very confused with the signal when the marketing position is not 1 or -1..i.e. with flat position, don't understand why the line after else goes like

Code: Select all

Sell ( "AtrLX-eb" ) next bar at High - var0 stop
, the position is flat, what is it for SELL? Likewise in the ATR Trialing SX coding what is it for BuytoCover?

I am trying to use this signal to exit in my HSI trading algo, and it always cause the buy and sell to happen within the same bar.

Hope someone experienced with this signal can give me some guidance.

Thanks

The original code source is here:

Code: Select all

[IntrabarOrderGeneration = false] inputs: ATRLength( 10 ), NumATRs( 3 ) ; variables: var0( 0 ), var1( 0 ), var2( 0 ) ; var0 = AvgTrueRange( ATRLength ) * NumATRs ; var1 = MarketPosition ; if var1 = 1 then begin condition1 = var1[1] <> 1 or High > var2 ; if condition1 then var2 = High ; Sell ( "AtrLX" ) next bar at var2 - var0 stop ; end else Sell ( "AtrLX-eb" ) next bar at High - var0 stop ;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Need some guidance with the ATR Trailing LX(SX) signal of MC

Postby TJ » 28 Oct 2018

The First Step in debugging is to . . .

Change the generic variable names to meaningful and understandable variable names


For example: Change these:
var0( 0 ), var1( 0 ), condition1 . . .

to these
MyATR( 0 ), MP( 0 ) . . . etc.,

User avatar
johnmok
Posts: 85
Joined: 18 Oct 2011
Has thanked: 30 times
Been thanked: 8 times

Re: Need some guidance with the ATR Trailing LX(SX) signal of MC

Postby johnmok » 20 Feb 2020

His code is simply copy from multicharts built in library, the built in signal "ATR trailing LX" wrote by Multicharts.

i've also got the same problem, the first part is pretty easy to understand.

while the second part is confusing, i would also like to know what "AtrLX-eb" use for.

thank you.

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 141 times

Re: Need some guidance with the ATR Trailing LX(SX) signal of MC

Postby Anna MultiCharts » 28 Feb 2020

Hello my2108,

The ‘else’ line is meant to protect the position on the bar where it was opened.
Please refer to the following description of the signal:
LX trailing stop based on ATR, it is activated immediately after entry; profit floor is not required because stop starts out loose; entry-bar protection is included.
This is not a strict trailing stop because the stop can actually loosen sometimes instead of always tightening. To convert to a strict trailing stop,
var0 should be fixed at the entry-bar for each position.
The IntrabarOrderGeneration attribute is set to false in this strategy because strategy calculations depend on end-of-bar prices. Specifically, the average true range calculation uses end-of-bar prices.


Return to “MultiCharts”