Exit on Close?

Questions about MultiCharts and user contributed studies.
jmi88
Posts: 29
Joined: 31 Jan 2007

Exit on Close?

Postby jmi88 » 19 Jun 2007

Im trying to backtest a system and I would like to have the position exit on the close of the day.....Is there a simple code for this? If Im long or short to exit on close.... Thankyou

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 20 Jun 2007

Please try to use setexitonclose.

jmi88
Posts: 29
Joined: 31 Jan 2007

Postby jmi88 » 20 Jun 2007

Thankyou, but for some reason it dosent reconize the word 'setexitonclose' and Im not real familiar with EL, can you give me an exapmle how to use it at the end of this sample code:

Code: Select all

inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ;
variables: FastAvg( 0 ), SlowAvg( 0 ) ;

FastAvg = AverageFC( Price, FastLength ) ;
SlowAvg = AverageFC( Price, SlowLength ) ;

if CurrentBar > 1 and FastAvg crosses over SlowAvg then

   Buy ( "MA2CrossLE" ) next bar at market ;
   

if CurrentBar > 1 and FastAvg crosses under SlowAvg then

   Sell Short ( "MA2CrossSE" ) next bar at market ;   

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Is SetExitOnClose added to the list of supported keywords?

Postby 2haerim » 20 Jun 2007

I thought SetExitOnClose is not currently supported yet.

Please confirm that which keywords and/or other things have been added to the list of currently supported list.

HR

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 21 Jun 2007

Setexitonclose is supported in the current beta.

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 21 Jun 2007

Thankyou, but for some reason it dosent reconize the word 'setexitonclose' and Im not real familiar with EL, can you give me an exapmle how to use it at the end of this sample code:

Code: Select all

inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ;
variables: FastAvg( 0 ), SlowAvg( 0 ) ;

FastAvg = AverageFC( Price, FastLength ) ;
SlowAvg = AverageFC( Price, SlowLength ) ;

if CurrentBar > 1 and FastAvg crosses over SlowAvg then

   Buy ( "MA2CrossLE" ) next bar at market ;
   

if CurrentBar > 1 and FastAvg crosses under SlowAvg then

   Sell Short ( "MA2CrossSE" ) next bar at market ;   


Just try to add this word at the end of your code.


Return to “MultiCharts”