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
2 registered members (Quad, aliswee), 835 guests, and 5 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
Unreliable PIPCost from Zorro EA #486332
08/01/22 11:30
08/01/22 11:30
Joined: Jul 2022
Posts: 5
Perth, Western Australia
F
faustotex Offline OP
Newbie
faustotex  Offline OP
Newbie
F

Joined: Jul 2022
Posts: 5
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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