Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 945 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
priceClose() always zero in TMF when trading Dax Future (IB) #468022
09/13/17 12:25
09/13/17 12:25
Joined: Feb 2017
Posts: 20
G
Gloria Offline OP
Newbie
Gloria  Offline OP
Newbie
G

Joined: Feb 2017
Posts: 20

Hi,

I'd be grateful for an explanation as to whether the following is a misunderstanding or a bug.

I am running the following simple test script "sample.c" in order to understand run() and tick() and how a TMF (trade management function) is called:

Code:
static int position;

int myTMS ( var hour, var minute) {

  if (TradeIsOpen) {

    printf ("\nopen trade: %f %f %f %f",priceOpen (),priceHigh (),priceLow (),priceClose ());
    if (timeOffset (CET,0,hour,minute) >= 0) {
      position = 0;
      return (5);
    }
  }

  return (4);
}

function run () {

  set (LOGFILE + NFA);

  if (is (INITRUN)) {

    History = ".t6";
    Lots = 1;
    LookBack = 1200;
    BarPeriod = 1;
    TickTime = 1;
    StartDate = 20170701;
    EndDate = 20170705;
    Verbose = 7;
    
    //asset ("DAX-FUT-20171215-FDAX-DTB-EUR");
    asset ("EURUSD");

    position = 0;
    
    return;
  }

  if ((timeOffset (CET,0,10,5) >= 0) && (timeOffset (CET,0,10,15) < 0) && (position == 0)) {
    position = 1;
    enterLong (myTMS,10,20);
  }
}

function tick () {
  printf ("\ntick: %f %f %f %f",priceOpen (),priceHigh (),priceLow (),priceClose ());

  if (day () != day (1)) {
    position = 0;
  }
}


Here myTMF() simply prints all price ticks while the position is open and then closes it at a given time. The strategy coded in run() opens the position at 10:05 local time and closes it at 10:20 via said TMF.

Now here is the behaviour that I don't understand. When I run this strategy as a backtest with the builtin EURUSD minute data (.t6), I get, as expected the log file
Code:
<snip>
[8368: Mon 17-07-03 08:04] (1.13904)
tick: 1.139100 1.139250 1.139090 1.139150
[8369: Mon 17-07-03 08:05] (1.13910)
[EURUSD::L6901] Long 1@1.13927  at 08:05:00
open trade: 1.139150 1.139340 1.139090 1.139180
tick: 1.139150 1.139340 1.139090 1.139180

[8370: Mon 17-07-03 08:06] +0 -0 0/1  (1.13915)
open trade: 1.139180 1.139310 1.139150 1.139250
tick: 1.139180 1.139310 1.139150 1.139250
[8371: Mon 17-07-03 08:07] +0 -0 0/1  (1.13918)
open trade: 1.139250 1.139290 1.139110 1.139170
tick: 1.139250 1.139290 1.139110 1.139170
<snip>


I see that the TMF is called immediately before the tick() function and with the same OHLC prices.

Now I use the Interactive Brokers (IB) backend where I have real-time data for the Dax future and use the Download.c script to obtain historical minute data of DAX-FUT-20171215-FDAX-DTB-EUR. When I backtest the above sample strategy with the Dax future, however, the log file shows
Code:
<snip>
[5161: Mon 17-07-03 08:04] (12381.00)
tick: 12382.000000 12382.000000 12377.500000 12379.000000
[5162: Mon 17-07-03 08:05] (12382.00)
[::L6201] Long 1@12379.00  at 08:05:00
Error 015: trade [::L6201] bad exit price 0.0000
[::L6201] Sell 1@0.00000: -12379$ at 08:05:00
tick: 12379.000000 12386.500000 12379.000000 12384.000000

[5163: Mon 17-07-03 08:06] -12379 +0 0/1  (12379.00)
tick: 12384.000000 12386.500000 12384.000000 12384.500000
[5164: Mon 17-07-03 08:07] -12379 +0 0/1  (12384.00)
tick: 12384.500000 12384.500000 12379.500000 12381.000000
<snip>


i.e. the trade is again entered at 10:05 local time, but immediately produces a "Bad Exit Price 0.0000" error. The downloaded minute data is fine, by the way, as I can see when I export to CSV. There are *no* spurious zero prices or similar.

It finally becomes apparent where the zero prices originate from as soon as I run the script in live trading with the actual (sub-minute) Dax future ticks. I changed the entry time to 13:47 because that was when I made the test. I also added a "Entry=0; Stop=0; TakeProfit=0; Trail=0;" in order to suppress any other TMF logic for this test:
Code:
<snip>
[1498: Wed 17-09-13 11:46] 12534/1253412534/12534
tick: 12533.500003 12533.500003 12533.500003 12533.500003
tick: 12533.500003 12533.500003 12533.000003 12533.000003
tick: 12533.500003 12533.500003 12532.500000 12532.500000
tick: 12533.500003 12533.500003 12532.000000 12532.000000
tick: 12533.500003 12533.500003 12532.000000 12532.500000
tick: 12533.500003 12533.500003 12532.000000 12533.000003
tick: 12533.500003 12533.500003 12532.000000 12532.500000
tick: 12533.500003 12533.500003 12532.000000 12533.000010
tick: 12533.500003 12533.500003 12532.000000 12532.500000
tick: 12533.500003 12533.500003 12532.000000 12532.000004
tick: 12533.500003 12533.500003 12531.500007 12531.500007
tick: 12533.500003 12533.500003 12531.500007 12532.500000
tick: 12533.500003 12533.500003 12531.500007 12533.000004
tick: 12533.500003 12533.500003 12531.500007 12532.500004
tick: 12533.500003 12533.500003 12531.500007 12533.000007
tick: 12533.500003 12533.500003 12531.500007 12532.500000
tick: 12533.500003 12533.500003 12531.500007 12533.000006
tick: 12533.500003 12533.500003 12531.500007 12532.500010
tick: 12533.500003 12533.500003 12531.500007 12532.000000
tick: 12533.500003 12533.500003 12531.500007 12532.500006
tick: 12533.500003 12533.500003 12531.500007 12532.000000
[1499: Wed 17-09-13 11:47] 12534/1253412532/12532
Enter 1L DAX-FUT-2017121  at 11:47:01
BrokerBuy DAX-FUT-20171215-FDAX-DTB-EUR: 152 ms
[DAX-FUT-2017121::L8273] Long 1@12532.00  at 11:47:01
Units: 1.0000 Margin: 0.00 MCost: 12531.0000 PCost: 0.01000
open trade: 0.000000 0.000000 0.000000 0.000000
tick: 12532.000007 12532.000007 12532.000007 12532.000007
open trade: 0.000000 0.000000 0.000000 0.000000
tick: 12532.000007 12532.500000 12532.000007 12532.500000
open trade: 0.000000 0.000000 0.000000 0.000000
tick: 12532.000007 12532.500000 12531.500006 12531.500006
<snip>


You can see that the TMF is always called with all four prices equal to zero.

Now if this is a consequence of trading the Dax future as opposed to a currency pair, that would explain the "Bad Exit Price 0.0000" problem - the system TMF that runs even before mine, sees the zero price ticks, too, and the position is stopped out at price 0.00 even before myTMF() get called for the first time.

I wonder whether I am somehow using the futures in a wrong setting or whether there is perhaps still a bug?

This happens both with Zorro 1.54 and 1.60.

Thanks for your help. Kind Regard,

Gloria

Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria] #468023
09/13/17 12:30
09/13/17 12:30
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I don't see the reason of the zero prices either. Does this only happen with IB and DAX futures, or with other assets also?

Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: jcl] #468034
09/14/17 11:11
09/14/17 11:11
Joined: Feb 2017
Posts: 20
G
Gloria Offline OP
Newbie
Gloria  Offline OP
Newbie
G

Joined: Feb 2017
Posts: 20
The same happens with the other Eurex futures using an IB connection. I don't have any other live data nor any other broker connections, and so this is the only case I can test.

Due to the "Bad exit price 0.0000" error during the backtest, however, I was suspecting that the problem is related to the instrument rather than to the broker. So I simply took the .t6 data file DAX-FUT-20171215-FDAX-DTB-EUR_2017.t6 that I downloaded from IB and renamed it to USDCHF_2017.t6, and voila when I say asset("USDCHF") in my script, it works as expected. No zero ticks in the TMF and no "Bad exit price 0.0000".

So it seems that you get zero prices whenever Zorro thinks it's a future whereas when it thinks it's a currency everything works as expected. Looks like a bug then.

Since I am planning to trade futures, I'd be grateful if you would fix it asap.

Kind regards,

Gloria

Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria] #468045
09/14/17 16:54
09/14/17 16:54
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I have just tested it, but not with DAX since I have not subscribed it, but with other futures, like ES-FUT-20171215-ES-GLOBEX. It does not happen here. Can you try it with the current beta version 1.62.2? I used it for testing and it is stable so far. It would be strange if only DAX produced a zero price, but other futures worked.

Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: jcl] #468059
09/15/17 07:14
09/15/17 07:14
Joined: Feb 2017
Posts: 20
G
Gloria Offline OP
Newbie
Gloria  Offline OP
Newbie
G

Joined: Feb 2017
Posts: 20

That was quick, thanks. It works indeed!

Regards,

Gloria

Last edited by Gloria; 09/15/17 08:23.
Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria] #468145
09/20/17 07:58
09/20/17 07:58
Joined: Feb 2017
Posts: 20
G
Gloria Offline OP
Newbie
Gloria  Offline OP
Newbie
G

Joined: Feb 2017
Posts: 20
.

Last edited by Gloria; 09/20/17 08:22.

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1