Risk per currency function

Avatar
  • updated
  • Fixed

I tested the function "risk per currency" to understand how it works.

Installed default set for 5 currency pairs on a demo account.

expertId:

eurusd - 1011

gbpusd - 1012

audusd - 1013

usdchf - 1014

usdjpy - 1015

Risk per currency properties (the same for each pair):

Type - by position number

Max risk value - 1.0

Opposite position calc mode - Netto Mode

Additional magic number list - 1011,1012,1013,1014,1015

Use semaphor - true

I expected the following:

with an open buy position on eurusd, positions will not be opened (until the eurusd position is opened):

buy - gbpusd, audusd

sell - usdchf, usdjpy

Further, I noticed that after the time elapsed, part of ea spontaneously turned off

From the EA logs, I noticed that at that moment an error occurred -  "invalid pointer access in 'RiskPerCurrency.mqh'". Also at this moment, a new signal appeared for another currency pair.

Has anyone encountered this? 
Is this a bug or incorrect settings EA?

And I understand the logic of the function correctly?

Pinned replies
Avatar
1
Andrey Khatimlianskyi
  • Answer

New parameter -- Consider only one position per EA (symbol/magic/type) -- is available in 2.54.11

Avatar
0
jay hu

I observed that while EUUSD trend up, USDCHF trend down in the recent market. The logic suppose while CP EA open buy position for EU pair based on active signal, no more buy for UCHF but sell is only allowed? Even those two pairs use same strategy or same signal say MA crossing.

Avatar
3
Andrey Khatimlianskyi
  • Under review

Thank you for your bug report!

It is a bug in Risk per currency library, of course.

Can you share your set file and expert logs? I'll investigate it and try to fix.

And yes, you understand function correctly. With buy EURUSD opened, no more buys for EURxxx or xxxUSD or sells for xxxEUR or USDxxx are allowed.