simulation execution not working as expected.

Questions about MultiCharts and user contributed studies.
chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

simulation execution not working as expected.

Postby chi jeongki » 22 Jul 2013

Version: MultiCharts64 Version 8.5 Release (Build 6851)

Trading begins from 9:00, the first bar of data1 is 09:07 assumed.
data1 and data2 are for the same instrument.

The immediate preceding data1 bar before data2 bar looks related to this symptom.
These bars are visited twice. First encouter at 10:59 executed L1, but the other encounter at 11:55, 12:58, 13:54 do not execute L2, L3, L4 and cnt was not increased.
Execution behavior should stick to one of first visit or second visit consistently, I think.

data1: 7 minute
data2: 1 hour

signal:

Var: datetime1(0), datetime2(0);
Var: cnt(0);

datetime1 = el_datetodatetime(Date data1) + ELTimeToDateTime_s(Time_s data1);
datetime2 = el_datetodatetime(Date data2) + ELTimeToDateTime_s(Time_s data2);

if Time < Time data2 then begin

cnt = cnt + 1;

Print(File("C:\test_log.csv"),
MaxBarsBack data1,",",
BarNumber data1,",",
CurrentBar data1,",",
FormatDate("yyyy-MM-dd",datetime1),",",
FormatTime("HH:mm:ss",datetime1),",",
open data1:6:2, ",",
high data1:6:2, ",",
low data1:6:2, ",",
close data1:6:2, ",",
Ticks data1:10:0,",,",
MaxBarsBack data2,",",
BarNumber data2,",",
CurrentBar data2,",",
FormatDate("yyyy-MM-dd",datetime2),",",
FormatTime("HH:mm:ss",datetime2),",",
open data2:6:2, ",",
high data2:6:2, ",",
low data2:6:2, ",",
close data2:6:2, ",",
Ticks data2:10:0, ",",
cnt);

buy("L1") this bar close;

end;

if Time = 1059 then buy ("L11") this bar close;
if Time = 1155 then buy ("L12") this bar close;
if Time = 1258 then buy ("L13") this bar close;
if Time = 1354 then buy ("L14") this bar close;

expected result:
order execution: L11, L12, L13, L14
cnt: 1, 1, 1, 1

result:
order execution: L1, L11, L12, L13, L14
cnt: 1, 2, 2, 2

Is it a bug or intended?

chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Re: simulation execution not working as expected.

Postby chi jeongki » 22 Jul 2013

To make execution behavior consistent,

Case1: stick to the first visit (doing nothing on the second visit)
L1, L11, L1, L12, L1, L13, L1, L14
printed cnt: 1, 2, 3, 4

Case 2: stick to the second visit (canceling the first visit)
L11, L12, L13, L14
not printed.

Case 3: stick to both visits
L1, L11, L1, L12, L1, L13, L1, L14
printed cnt: 1, 2, 3, 4

case 4: stick to the second visit (canceling the first visit, but printing is not canceled)
L11, L12, L13, L14
printed cnt: 1, 1, 1, 1
but the value of cnt after L14 is executed should be 0, since variable change should have been canceled.

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

Re: simulation execution not working as expected.

Postby TJ » 22 Jul 2013

[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

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

Re: simulation execution not working as expected.

Postby TJ » 22 Jul 2013

::
expected result:
order execution: L11, L12, L13, L14
cnt: 1, 1, 1, 1

result:
order execution: L1, L11, L12, L13, L14
cnt: 1, 2, 2, 2

Is it a bug or intended?
Why would you expect the first order is L11?

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

Re: simulation execution not working as expected.

Postby TJ » 22 Jul 2013

Code: Select all

buy("L1") this bar close;
Just in case you are not aware:

see post #7
[FAQ] This Bar on Close
viewtopic.php?f=16&t=10811


Return to “MultiCharts”