Gamestudio Links
Zorro Links
Newest Posts
Bulk-parse CSV files from whole directory
by jack_the_whack. 08/13/22 07:57
Zorro_setup.exe detected with virus
by Grant. 08/12/22 09:03
ARM support for Zorro?
by AndrewAMD. 08/11/22 19:54
DeepLearn script
by jcl. 08/10/22 12:58
New Zorro version 2.50
by hast29. 08/09/22 15:50
linux
by AndrewAMD. 08/08/22 14:23
AUM Magazine
Latest Screens
DEAD TASTE
Tactics of World War I
Hecknex World
Scheherazade's Journey
Who's Online Now
5 registered members (monarch, nerdkorea, Quad, jack_the_whack, 1 invisible), 436 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
boony, jack_the_whack, MrMan, nerdkorea, marconius
18812 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Unreliable PIPCost from Zorro EA #486332
08/01/22 11:30
08/01/22 11:30
Joined: Jul 2022
Posts: 4
Perth, Western Australia
F
faustotex Offline OP
Guest
faustotex  Offline OP
Guest
F

Joined: Jul 2022
Posts: 4
Perth, Western Australia
Zorro ver 4.50.

I am specifically referring to the extraction of parameters from the MT4 platform. Before posting here I did search for a concrete asset example but could not find one among the brokers I have access to these days. However, here it goes:

Athough not usually a problem with Forex assets, there can be assets where TickSize is other than one Point i.e. some brokers may only issue a new quote every N points where N can be 2, 4, 25, etc.

For this reason traditionally in the MT4 world:

PointCost = MarketInfo(Asset,MODE_POINT) * MarketInfo(Asset,MODE_TICKVALUE) / MarketInfo(Asset,MODE_TICKSIZE);

The ratio TICKVALUE/TICKSIZE scales TICKVALUE down to give us the true Value or Cost of one Point when TICKSIZE is greater than one Point.

This issue has gone unnoted for a long time because more frequently than not the missing parameters MarketInfo(Asset,MODE_POINT) / MarketInfo(Asset,MODE_TICKSIZE) = 1.0.

Your original expression in the Zorro EA will return a wrong PIPCost for every asset which has a TICKSIZE greater than one Point:

arr[4] = PIPCost = MarketInfo(Asset,MODE_TICKVALUE) * LotFactor * Factor; // pipcost

The corrected code could be:

arr[4] = PIPCost = MarketInfo(Asset,MODE_POINT) * (MarketInfo(Asset,MODE_TICKVALUE) / MarketInfo(Asset,MODE_TICKSIZE)) * LotFactor * Factor); // corrected pipcost

Simplifying (POINT * Factor) = PIP and adding protection against the dreaded, unpredictable, far too frequent MT4 "divide by zero" error, we have:

arr[4] = PIPCost = PIP * (MarketInfo(Asset,MODE_TICKVALUE) / MathMax(MarketInfo(Asset,MODE_TICKSIZE),1e-10)) * LotFactor; // true pipcost

I further notice that several parameters are calculated more than once in Zorro EA, including PIPCost, which is also calculated within the block #ifdef EXAMINE.

So I recommend corrections be applied to both places. Needless to say, ideally calculations would better be done only once right up front, as early as possible, then used severally as needed.

Addendum: Here are some examples of Metals and Commodities from two distinct brokers :

2022.08.03 19:36:16.871 TickSizeVsPoint EURUSD,H1: Of all assets examined 36 have TICKSIZE of one POINT
2022.08.03 19:36:16.871 TickSizeVsPoint EURUSD,H1: Ahah! Platinum: TickValue= 1.00000, Point= 0.01000, TickSize= 0.05000, correct PIPCost= 0.0020000000
2022.08.03 19:36:16.871 TickSizeVsPoint EURUSD,H1: Ahah! Palladium: TickValue= 1.00000, Point= 0.01000, TickSize= 0.05000, correct PIPCost= 0.0020000000
2022.08.03 19:36:16.871 TickSizeVsPoint EURUSD,H1: Broker: FBS Inc

2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! #QMV22: TickValue= 10.00000, Point= 0.00100, TickSize= 0.03000, correct PIPCost= 0.0333333333
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! #QMU22: TickValue= 10.00000, Point= 0.00100, TickSize= 0.03000, correct PIPCost= 0.0333333333
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! #QMQ22: TickValue= 10.00000, Point= 0.00100, TickSize= 0.03000, correct PIPCost= 0.0333333333
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! #PLF: TickValue= 10.00000, Point= 0.10000, TickSize= 0.50000, correct PIPCost= 0.0200000000
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! #PAF: TickValue= 10.00000, Point= 0.01000, TickSize= 0.50000, correct PIPCost= 0.0020000000
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Ahah! SILVER: TickValue= 2.50000, Point= 0.00100, TickSize= 0.00500, correct PIPCost= 0.0500000000
2022.08.03 15:14:29.362 TickSizeVsPoint EURUSD,H1: Broker: InstaForex


Last edited by faustotex; 08/03/22 12:30.
Re: Unreliable PIPCost from Zorro EA [Re: faustotex] #486335
08/02/22 13:17
08/02/22 13:17
Joined: Jul 2000
Posts: 27,871
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,871
Frankfurt
Thanks for the info - that looks plausible. I'm no MT4 expert, but we'll check if we can find MT4 assets where tick size is different to point size, and will correct the code.


Moderated by  jcl, Nems, Spirit, Tobias 

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