MACD Crossover Signal, and then Trailing Stop.  [SOLVED]

Questions about MultiCharts and user contributed studies.
monkey88

MACD Crossover Signal, and then Trailing Stop.

Postby monkey88 » 27 Aug 2011

Hello,

I am trying to make a script, for when a MACD crosses over and then, enter a trailing stop, do I just copy the settraiingstop script into the MACD LE / SE script and it shall work?

Thanks

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: MACD Crossover Signal, and then Trailing Stop.

Postby Stan Bokov » 29 Aug 2011

Yeah, you can do that in the full MC, but not in MCDT. Basically you'll need to incorporate the trailing stop into the MACD signals, just like you said. Make sure you test your scripts so that you see they are working ok before you trade though.

Guest

Re: MACD Crossover Signal, and then Trailing Stop.  [SOLVED]

Postby Guest » 29 Aug 2011

Hi there,

Maybe I have put this in the wrong forum bit, but yes I am using just Multi Charts, NOT the DT.


Here is the code, but I do not think that the trailingstop is working:

inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;

condition1 = CurrentBar > 2 and var2 crosses over 0 ;
if condition1 then
Buy ( "MacdLE" ) this bar at market ;


[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), Amount( 1 ) ;

if PositionBasis then
SetStopPosition
else
SetStopShare ;

SetDollarTrailing( 10 ) ;





inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;

condition1 = CurrentBar > 2 and var2 crosses under 0 ;
if condition1 then
Sell Short ( "MacdSE" ) this bar at market ;

[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), Amount( 1 ) ;

if PositionBasis then
SetStopPosition
else
SetStopShare ;

SetDollarTrailing( 10 ) ;

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

Re: MACD Crossover Signal, and then Trailing Stop.

Postby TJ » 29 Aug 2011

Please use code tag when posting codes. It makes reading codes easier.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MACD Crossover Signal, and then Trailing Stop.

Postby Henry MultiСharts » 30 Aug 2011

Please provide us addition information regarding the issue.
What do you mean by "I do not think that the trailingstop is working" ?
Is the order sent with the incorrect price or it is not sent at all?
Who is the data feed and what are the symbol settings in the QUote manager?
Please attach a screenshot of the settings tab.
What autotrading mode do you use (sync or async)?
Who is your broker?


Return to “MultiCharts”