Gamestudio Links
Zorro Links
Newest Posts
Deformers struct in MDL7 abspeichern.
by tagimbul
Today at 02:06
Votes for future features
by Hredot
Today at 01:48
What happens with particles, Memory wise?
by jumpman
Today at 00:41
Plotting on hour time scale
by Hredot
Yesterday at 17:42
Fetter ACSII Parser
by MasterQ32
Yesterday at 14:31
AUM Magazine
Latest Screens
RPG PARTY
Triton Wing now available on Steam
AckCon'17: Lotter vs The World
Triton Wing
ZeaL
Who's Online
7 registered (Dalla, AndrewAMD, firecrest, jyd, tagimbul, johnnyp, jrath), 444 Guests and 4 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
CaptainPablo, blAx, BBX, jcadihere, Peeyotch
17759 Registered Users
Topic Options
Rate This Topic
#468022 - 09/13/17 14:25 priceClose() always zero in TMF when trading Dax Future (IB)
Gloria Offline
Newbie

Registered: 02/28/17
Posts: 11

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

Top
#468023 - 09/13/17 14:30 Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 25721
Loc: 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?

Top
#468034 - 09/14/17 13:11 Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: jcl]
Gloria Offline
Newbie

Registered: 02/28/17
Posts: 11
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

Top
#468045 - 09/14/17 18:54 Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 25721
Loc: 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.

Top
#468059 - 09/15/17 09:14 Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: jcl]
Gloria Offline
Newbie

Registered: 02/28/17
Posts: 11

That was quick, thanks. It works indeed!

Regards,

Gloria


Edited by Gloria (09/15/17 10:23)

Top
#468145 - 09/20/17 09:58 Re: priceClose() always zero in TMF when trading Dax Future (IB) [Re: Gloria]
Gloria Offline
Newbie

Registered: 02/28/17
Posts: 11
.


Edited by Gloria (09/20/17 10:22)

Top



Gamestudio download | chip programmers | Zorro platform | shop | resources | magazine | manual | support faq | bugs | beta features

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) 3dgamestudio.net