SETEXITONCLOSE in auto trading

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

SETEXITONCLOSE in auto trading

Postby ppan » 27 Aug 2008

The SETEXITONCLOSE cannot close all the open positions before the market close in auto trading. How to use the SETEXITONCLOSE in Auto Trading?

khalaad
Posts: 312
Joined: 07 Jan 2007
Location: Lahore, Pakistan
Has thanked: 62 times
Been thanked: 57 times

Postby khalaad » 28 Aug 2008

ppan

SetExitonClose may only be used when testing, not live trading.

I do not thing it is advisable to close an open position when trading live via a general command; such command should be congruent with the rest of the code.

Khalid

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Re: SETEXITONCLOSE cannot be used in auto trading

Postby SUPER » 28 Aug 2008

The SETEXITONCLOSE cannot close all the open positions before the market close in auto trading. How to use the SETEXITONCLOSE in Auto Trading?


You can use time based condition to exit something like:

Code: Select all

Input: MyTime(1528);

If time >= MyTime then begin

  Sell ("_LX_") Next Bar at Market;
  BuytoCover("_SX_") Next Bar at Market;

end;


Regards
Super

khalaad
Posts: 312
Joined: 07 Jan 2007
Location: Lahore, Pakistan
Has thanked: 62 times
Been thanked: 57 times

Postby khalaad » 28 Aug 2008

Super,

What you have suggested is correct as far as exits are concerned.

But one will also need to ensure there are NO NEW ENTRIES between the MyTime exit and daily close!

Then there could the matter of IBOG being TRUE or FALSE.

Khalid

ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

Postby ppan » 28 Aug 2008

Super,

Your code is correct but I should use 1 min or 5 min bar to run the system. If I use 30 min bar or 15 min bar, the system will exit 30 min or 15 min before the market close. The exit price and the real market close may have a big difference.

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Postby SUPER » 29 Aug 2008

Super,

Your code is correct but I should use 1 min or 5 min bar to run the system. If I use 30 min bar or 15 min bar, the system will exit 30 min or 15 min before the market close. The exit price and the real market close may have a big difference.


The code reads computer time so it should not matter, however you have to remeber what Khalaad suggested.

There is a very elgant code posted on TS forum by Goose and I use it with great effect. (EoD Exit)

Message me if you do not have access to TS forum.

Regards
Super

ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

Postby ppan » 29 Aug 2008

Super,

Where is the code?

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Postby SUPER » 30 Aug 2008

Super,

Where is the code?


Here's link to the code you are looking for.

https://www.TS.com/Discussion ... xactMatch=

Regards
Super

aljafp
Posts: 184
Joined: 28 Oct 2005
Been thanked: 1 time

Postby aljafp » 30 Aug 2008

Super,

Where is the code?


Here's link to the code you are looking for.

https://www.TS.com/Discussion ... xactMatch=

Regards
Super


hi,
some of us don't have access to TS forum,
could you kindly paste the code here ?

thanks appreciate it.

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Postby SUPER » 31 Aug 2008

Super,

Where is the code?


Here's link to the code you are looking for.

https://www.TS.com/Discussion ... xactMatch=

Regards
Super


hi,
some of us don't have access to TS forum,
could you kindly paste the code here ?

thanks appreciate it.


Here's it.

[/code]
Attachments
Eod Exit.ELD
(11.28 KiB) Downloaded 222 times

ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

Postby ppan » 01 Sep 2008

Thanks for your code. Very useful.


Return to “User Contributed Studies and Indicator Library”