Help: IOG Enabled Code

Questions about MultiCharts and user contributed studies.
Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Help: IOG Enabled Code

Postby Spaceant » 10 Nov 2009

Hi,

I am testing the following code in a 1-min chart
[IntrabarOrderGeneration = True];
Inputs:TT1(81908),TT2(82218);
Vars:TEnt(0), TExit(0);

TEnt=Iff(Currenttime_S>=TT1,1,0);
TExit=Iff(Currenttime_S>=TT2,1,0);

If TEnt=1 then buy this bar at close;
If TExit=1 then sell this bar at close;

I was testing the code at around 8:15:00 with the following expectation.

Expectation: I anticipate that a Buy order would be executed at 8:19:08. And a Sell order would be executed at 8:22:18.

However, the Buy order was executed just after 8:20 (or it is like an end-of-bar signal); while the Sell order was executed just after 8:23 (it is like an end-of-bar signal).

Similarly, I have tested the code on a 5-min chart. The signals were executed as end-of-bar signals.

Could anyone help me to fix it?

One more question: How can I make the code / setting to let MC to issue repetitive signals, e.g for the Buy signal after 8:19:08?

Sa
p/s Additional settings:
Tested currency: EURUSD
Tested account: IB paper trading account
Strategy Properties:
Position Limit (haven't checked anything)
Fixed Shares / Contracts: 20000

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

Postby TJ » 10 Nov 2009

when you say "testing",

do you mean BACKTESTING ?

or forward testing?


there is a difference.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 10 Nov 2009

Sorry for not being expicit

I meam forward testing with my paper trading account......

I think the code with currenttime_s can't be backtested, am I right?

Sa

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

Postby TJ » 10 Nov 2009

Sorry for not being expicit

I meam forward testing with my paper trading account......

I think the code with currenttime_s can't be backtested, am I right?

Sa

you are right... "current" cannot be backtested.

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

Postby TJ » 10 Nov 2009

I know you have IntrabarOrderGeneration in your code,

did you also enable it at the Format Signal?

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

Postby TJ » 10 Nov 2009

try this:

Code: Select all

If TEnt=1 then buy this bar at close;
If TExit=1 then sell this bar at close;
change to

Code: Select all

If TEnt=1 then buy next bar at market;
If TExit=1 then sell next bar at market;

see this for further information:
http://forum.tssupport.com/viewtopic.php?t=6835

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 10 Nov 2009

I know you have IntrabarOrderGeneration in your code,

did you also enable it at the Format Signal?
I may have missed that, where to set in Format Signal?

Sa

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

Postby TJ » 10 Nov 2009

I know you have IntrabarOrderGeneration in your code,

did you also enable it at the Format Signal?
I may have missed that, where to set in Format Signal?

Sa

right click on chart...

select Format Signal

select IntrabarOrderGeneration tab

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 10 Nov 2009

Do you mean the tab under Format of the Signal? There are three choices:

Limit each order command in this signal to one entry and one exit per bar
Limit this signal to one entry and one exit per bar
Allow unlimited entries and exits per bar

If I want to have one signal only (only the first signal), which one should I choose from the first two?

.... really don't understand the difference for these two?

I am still using 5.0 Gold.... is IOG working alright with 5.0?

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

Postby TJ » 10 Nov 2009

you are in the right place...

option #1
Each command (ie order trigger) can fire off ONE order per bar
if there are multiple commands,
that bar might have multiple orders...
but each command can only fire once.

option #
Each BAR can have one buy and one sell order only.
if there are multiple commands, or multiple triggers,
the first one triggered will be sent,
the rest are disregarded.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 10 Nov 2009

option #
Each BAR can have one buy and one sell order only.
if there are multiple commands, or multiple triggers,
the first one triggered will be sent,
the rest are disregarded.
The fact is that my forward tested result was with the above setting, in which the "Enable Intra-bar Order Generation" can't be unchecked.

I don't know what has been going on, that MC couldn't really execute an IOG trigger as I tested.....

Strange, but need help

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

Postby TJ » 10 Nov 2009

option #
Each BAR can have one buy and one sell order only.
if there are multiple commands, or multiple triggers,
the first one triggered will be sent,
the rest are disregarded.
The fact is that my forward tested result was with the above setting, in which the "Enable Intra-bar Order Generation" can't be unchecked.

I don't know what has been going on, that MC couldn't really execute an IOG trigger as I tested.....

Strange, but need help

see post #6

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 11 Nov 2009

try this:

Code: Select all

If TEnt=1 then buy this bar at close;
If TExit=1 then sell this bar at close;
change to

Code: Select all

If TEnt=1 then buy next bar at market;
If TExit=1 then sell next bar at market;

see this for further information:
http://forum.tssupport.com/viewtopic.php?t=6835
TJ,

Do you mean this?

I have tested it on two computers, one in XP one in Vista. The former one works while it appears to be not working in Vista....... may need to retest it again in Vista.....

Well, with the above result, does it mean that buy / sell this bar at close doesn't with IOG enabled codes????

Sa

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

Postby TJ » 11 Nov 2009

may I suggest...


1. re-read post#6... last line


2. go to this page and download this free eBook:
Intrabarordergeneration is explained on page 82.
The essential EasyLanguage programming guide allows you to quickly look up usage and syntax concepts and examples for the most commonly used features of EasyLanguage.
http://www.tssupport.com/support/tutorials/


.


Return to “MultiCharts”