1 registered members (rki),
405
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
1.79 - Spread and marketVal() in test mode
#471438
03/04/18 12:05
03/04/18 12:05
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Am I doing something wrong or is the spread in test mode with marketVal() not propperly supported?
function tick() {
if(is(TESTMODE))
Spread = marketVal();
printf("n%04d-%02d-%02d %02d:%02d:%02.3f, %s: %.5f, Spread: %.5f", year(),month(),day(),hour(),minute(),second(),Asset, priceClose(), Spread);
}
}
function run() {
LookBack = 0;
History = ".t1";
StartDate = 20180302;
set(TICKS+LOGFILE);
}
produces following log:
V 1.797 on Sun 18-03-04 12:56:33
Test: ShowSpread EUR/USD (TICKS) 2018
2018-03-02 01:00:0.033, EUR/USD: 1.22735, Spread: 0.00000
2018-03-02 01:00:0.233, EUR/USD: 1.22734, Spread: 0.00000
2018-03-02 01:00:0.420, EUR/USD: 1.22734, Spread: 0.00000
2018-03-02 01:00:0.996, EUR/USD: 1.22733, Spread: 0.00000
2018-03-02 01:00:1.002, EUR/USD: 1.22731, Spread: 0.00000
2018-03-02 01:00:1.027, EUR/USD: 1.22729, Spread: 0.00000
2018-03-02 01:00:1.043, EUR/USD: 1.22728, Spread: 0.00000
2018-03-02 01:00:1.109, EUR/USD: 1.22729, Spread: 0.00000
2018-03-02 01:00:1.216, EUR/USD: 1.22728, Spread: 0.00000
2018-03-02 01:00:1.308, EUR/USD: 1.22728, Spread: 0.00000
while the corresponding .t1 (in ZHistoryEditor, downloaded from FXCM with assetHistory(Asset,0)):
2018.03.02 01:00:01.308 1,22728
2018.03.02 01:00:01.308 -1,22727
2018.03.02 01:00:01.215 1,22728
2018.03.02 01:00:01.108 1,22729
2018.03.02 01:00:01.043 1,22728
2018.03.02 01:00:01.026 1,22729
2018.03.02 01:00:01.002 1,22731
2018.03.02 01:00:00.996 1,22733
2018.03.02 01:00:00.996 -1,22732
2018.03.02 01:00:00.419 1,22734
2018.03.02 01:00:00.419 -1,22732
2018.03.02 01:00:00.233 1,22734
2018.03.02 01:00:00.233 -1,22733
2018.03.02 01:00:00.033 1,22735
2018.03.02 01:00:00.033 -1,22733
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: jcl]
#471467
03/05/18 16:39
03/05/18 16:39
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Spread is only stored for bars, not for ticks. This is exactly what one expects if he read in the manual: If .t1 data contains both ask and bid quotes, marketVal returns the recent ask-bid spread I would laugh about if I didn't waste much time searching for errors in my code.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: jcl]
#471470
03/05/18 17:03
03/05/18 17:03
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
This is on our list for the next update - spreads will then be stored by tick. Will plugins be needing to support a new tick struct? Or will Zorro simply interpret the T1 data differently?
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Sphin]
#471634
03/12/18 09:16
03/12/18 09:16
|
Joined: Jul 2000
Posts: 27,982 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,982
Frankfurt
|
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: jcl]
#471670
03/13/18 17:45
03/13/18 17:45
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Great! BTW: I tried to work around using a BarPeriod of 1./60 and learned that it is useless setting it lower than one hour concerning to the spread. But Zorro reacted generally very angry to this attempt, it mixes up times (time of the end of the trade is before its start and not even of the bar period) and also the 10,000-times-higher-due-to-the-Forex-multiplicator problem appeared again (1.79.8): [95: Mon 18-02-26 01:34:04] 0000 -1200 0/2 (1.39684).... [EURUSD_B1::S9601] Short 1@1.22998 at 01:36:00 [EURUSD_B2::L9602] Long 1@1.23001 at 01:36:00 [EURUSD_B2::L9602] Sell 1@1.22999: -600 at 01:35:01 [EURUSD_B1::S9601] Cover 1@1.22989: -600 at 01:35:01
[96: Mon 18-02-26 01:35:03] -1200 -1354 1/3 .... Maybe those BarPeriods are not for broker arbitrage scripts?
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Sphin]
#471786
03/19/18 19:41
03/19/18 19:41
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
marketVal and marketVol can now also be called in a TMF or tick function. Spread still changes according to BarPeriod, not per tick (1.80.4) or shouldn't this not being implemented yet? Additionally there are mysterious time hoppings during tick function like: [...] 2018-02-07 01:53:49.046, EUR/USD: 1.23875, Spread: 0.00002 2018-02-07 01:53:49.090, EUR/USD: 1.23876, Spread: 0.00002 2018-02-07 01:53:53.323, EUR/USD: 1.23875, Spread: 0.00002 2018-02-07 01:53:53.360, EUR/USD: 1.23875, Spread: 0.00002 2018-02-07 01:53:53.603, EUR/USD: 1.23876, Spread: 0.00002 2018-02-07 01:53:56.414, EUR/USD: 1.23875, Spread: 0.00002 2018-02-07 01:54:59.783, EUR/USD: 1.23875, Spread: 0.00002 2018-02-07 01:54:59.791, EUR/USD: 1.23874, Spread: 0.00002 [12: Wed 18-02-07 01:54:00] (1.23874) 2018-02-07 01:54:0.321, EUR/USD: 1.23874, Spread: 0.00002 2018-02-07 01:54:0.335, EUR/USD: 1.23873, Spread: 0.00002 2018-02-07 01:54:5.518, EUR/USD: 1.23873, Spread: 0.00002 [...] The script is the same as at the begin of this thread, added BarPeriod = 1.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: jcl]
#471893
03/24/18 10:19
03/24/18 10:19
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Waited till weekend and with 1.80.6 it's really confusing because Spread=marketVal() now contains a price and it seems to be priceClose(-1) that means peeking one tick into future: [1: Mon 18-03-05 00:01:00] (1.23173) 2018-03-05 00:01:0.039, EUR/USD: 1.23174, Spread: 1.23173 2018-03-05 00:01:2.644, EUR/USD: 1.23173, Spread: 1.23172 2018-03-05 00:01:2.655, EUR/USD: 1.23172, Spread: 1.23171 2018-03-05 00:01:2.688, EUR/USD: 1.23171, Spread: 1.23170 2018-03-05 00:01:2.718, EUR/USD: 1.23170, Spread: 1.23171 2018-03-05 00:01:4.305, EUR/USD: 1.23171, Spread: 1.23170 2018-03-05 00:01:6.248, EUR/USD: 1.23170, Spread: 1.23171 2018-03-05 00:01:6.771, EUR/USD: 1.23171, Spread: 1.23172
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Sphin]
#472097
04/07/18 11:54
04/07/18 11:54
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
So far my test results with the "simple broker arbitrage example" with a threshold factor of 2.5 extended by some plot functions and Zorro 1.80.8: 1. TEST with history FXCM from assetHistory / ActiveTrades from storing (recording) within the tick function on demo account: Test BA_EURUSD (TICKS) Bar period: 1 min (avg 1 min) Test period: 2018-04-02..2018-04-06 (6955 bars) Lookback period: 0 bars (0 minutes) Simulation mode: Realistic ticks (slippage 5.0 sec) Spread: marketVal() Number of trades: 580 (43474/year, 837/week, 173/day) SpreadA is from ActiveTrades, SpreadB from FXCM 2. TEST with history both FXCM and ActiveTrades from storing (recording) within the tick function on demo account: Test BA_EURUSD (TICKS) Bar period: 1 min (avg 1 min) Test period: 2018-04-02..2018-04-06 (6955 bars) Lookback period: 0 bars (0 minutes) Simulation mode: Realistic ticks (slippage 5.0 sec) Spread: marketVal() Number of trades: 8 (600/year, 12/week, 3/day) 3. TRADE (Demo Accounts) with FXCM / ActiveTrades: Bar period: 1 min (avg 1 min) Trade period: 2018-04-02..2018-04-06 Spread: Live spread from broker Number of trades: 2 (167/year, 4/week, 1/day) For the only difference between 1 and 2 is the source of the FXCM prices it can be suspected that the spreads in their history loaded with assetHistory is another than stored within a tick function. But this does not explain all because although the spread from ActiveTrades is directly stored in the tick function it differs strongly between test and trade scenario. I don't know if these differences can be avoided in general or if they are of systemic ones but IMO those back test results should be regarded very carefully, they can be much too optimistic (the test under point 1 has a PF of 2.34 (2.07) and a pairwise win rate of 82%). Would be nice if this could be realized.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Zheka]
#472107
04/08/18 16:43
04/08/18 16:43
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Good point. I don't think there is any slippage involved. If I read the log right it seems the trades are opened the or next second the threshold's break was found: 2018-04-02 11:58:33.4425 AssetA: EURUSD_AT, PriceA: 1.23424, SpreadA: 0.00000, CommissionA: 0.00007 AssetB: EURUSD_FXCM, PriceB: 1.23382, SpreadB: 0.00001, CommissionB: 0.00007 Difference: 0.00042, Threshold: 0.00038 [EURUSD_AT::S1901] Short 1@1.23414 at 11:58:33 [EURUSD_FXCM::L1902] Long 1@1.23401 at 11:58:33 [...] 2018-04-02 13:24:36.8495 AssetA: EURUSD_AT, PriceA: 1.23296, SpreadA: 0.00000, CommissionA: 0.00007 AssetB: EURUSD_FXCM, PriceB: 1.23332, SpreadB: 0.00000, CommissionB: 0.00007 Difference: -0.00036, Threshold: 0.00035 [EURUSD_AT::L0501] Long 1@1.23303 at 13:24:37 [EURUSD_FXCM::S0502] Short 1@1.23313 at 13:24:37 [...] 2018-04-02 13:47:54.9835 AssetA: EURUSD_AT, PriceA: 1.23185, SpreadA: 0.00000, CommissionA: 0.00007 AssetB: EURUSD_FXCM, PriceB: 1.23232, SpreadB: 0.00003, CommissionB: 0.00007 Difference: -0.00047, Threshold: 0.00043 [EURUSD_AT::L2801] Long 1@1.23177 at 13:47:55 [EURUSD_FXCM::S2802] Short 1@1.23220 at 13:47:55 [...] Slippage and Fill have default values, so there should be 5 sec slippage as you mentioned, maybe there is another treatment when trading on .t1?
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Zheka]
#472144
04/11/18 11:38
04/11/18 11:38
|
Joined: Dec 2017
Posts: 129 Halifax, NS
kujo
Member
|
Member
Joined: Dec 2017
Posts: 129
Halifax, NS
|
I wonder what the reason is for spread difference between Trade and Test of ActiveTrades?
When it comes to TEST: Does marketVal() return correct values? Are they in line with your own calculation?
The same questions for TRADE: does spread that is returned by the broker is in line with your calculation based on ticks?
Last edited by kujo; 04/11/18 11:45.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: kujo]
#472145
04/11/18 16:03
04/11/18 16:03
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
The time differences are marginal, these are the corresponding ticks from AT:
2018.04.02 11:58:33.441 1,23424 2018.04.02 13:24:36.848 1,23296 2018.04.02 13:47:54.982 1,23185
I don't know if marketVal() return the right values, if I regard the ticks from above again and verify them against the last bid price, I calculate the following:
2018.04.02 11:58:33.441 1,23424 2018.04.02 11:58:33.441 -1,23419 (2018.04.02 11:58:32.988 1,23425) (2018.04.02 11:58:32.988 -1,23419) => calculated spread: 0.00005, spread by marketVal(): 0.00000
2018.04.02 13:24:36.848 1,23296 2018.04.02 13:24:36.848 -1,23291 (2018.04.02 13:24:35.364 -1,23291) => calculated spread: 0.00005, spread by marketVal(): 0.00000
2018.04.02 13:47:54.982 1,23185 2018.04.02 13:47:54.982 -1,2318 (2018.04.02 13:47:54.482 1,23186) (2018.04.02 13:47:54.482 -1,23181) => calculated spread: 0.00005 (0.00004), spread by marketVal(): 0.00000
Ticks in parentheses are the ticks before because jcl meant the bid price before could be significant, but in no case I come to the values marketVal() returns. There can be 2 reasons: I calculate wrong or marketVal() calculates wrong.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: Sphin]
#472150
04/12/18 13:22
04/12/18 13:22
|
Joined: Dec 2017
Posts: 129 Halifax, NS
kujo
Member
|
Member
Joined: Dec 2017
Posts: 129
Halifax, NS
|
Hmm, it should be easy as 1,2,3. It looks like a bug. Have you written to support about marketVal()? How they explain zeros? Do you use the latest beta version?
Last edited by kujo; 04/12/18 13:23.
|
|
|
Re: 1.79 - Spread and marketVal() in test mode
[Re: kujo]
#472501
05/01/18 09:29
05/01/18 09:29
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
void tick()
{
T1* Bid = dataAppendRow(1,2);
Bid->time = wdate();
Bid->fVal = -(priceClose()-Spread);
T1* Ask = dataAppendRow(1,2);
Ask->time = wdate();
Ask->fVal = priceClose();
}
void click()
{
dataSort(1);
dataSave(1,strf("History\%s_2018.t1",strx(Asset,"/","")));
quit("Done!");
}
void run()
{
BarPeriod = 1;
LookBack = 0;
panelSet(-1,-1,"Save");
}
|
|
|
|