Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1952
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon everyone.
I need your help.
The EA has a built-in counting function for the current profit:
void OnTick is made as above.
How to make profit counter reset to 0.0 when conditions are met:
if(CountOrders()==0) && (GetProfitFromStart()>0
I.e., all orders are closed and the total profit when the last order is closed was >0?
This task is not quite clear. Each time the calculation function starts to go through the orders/positions and summarizes the profits from zero.
What do you want to zero out? If you have no open positions/market orders, the counting function will return zero. It will zero itself)))
Good afternoon everyone.
I need your help.
How to make the profit counter reset to 0.0 when conditions are met:
i.e. all orders closed and the total profit when the last order closed was >0???
What exactly of this does not work?
Good afternoon. Please help.
Looking for closed orders with negative returns.
By totals it misses, I do not get the result of all negative orders.
I am learning to write.
Good afternoon. Please help.
Looking for closed orders with negative returns.
By totals it misses, I do not get the result of all negative orders.
I am trying to learn how to write.
At a quick glance, I see that you are looking through the positions from the end and at the same time, you write the closing time in the variable. It may turn out that you have captured the time of the most recently closed position and the next condition will no longer be true:
as other positions have lower closing times. This will all depend on the sorting, but in standard sorting this is the problem.
Also fix this condition
to
If we take a position from the history, OrderProfit() will already store the final result with swaps and commission. In open positions - no, everything must be summed up. But this is not certain, check it.
At a quick glance, I see that you are looking through the positions from the end and you are writing the closing time into the variable. It may turn out that you have captured the time of the most recently closed position and the next condition will no longer be true:
as other positions have lower closing times. This will all depend on the sorting, but in standard sorting this is the problem.
Also fix this condition
to
If we take a position from the history, OrderProfit() will already store the final result with swaps and commission. In open positions - no, everything must be summed up. But this is not accurate, please check.
Thank you. This works fine.
Further; when we come across an order with a positive profit, we should reset the result and look for negative ones.
Good afternoon. Please help.
Looking for closed orders with negative returns.
By totals it misses, I do not get the result of all negative orders.
I am learning to write.
I recommend using a debugger for this and similar situations.
Good afternoon.
Faced with a lack of understanding of how ".Search()" in the standard library.
I am using standard class - CiTime() - The class is a class to access bar opening time series.
When trying to find the Date I need (class is the same but Period is different)
int k = TimeFrac.Search( Time.GetData(i) );
Makes an error:
'GetData' - parameter conversion not allowed.
Tried to replace
to
datetime Time_GetData = Time.GetData(i);
Doesn't work...
I've referred to the Help. It says there
And a wild application example.
It turns out that searching for a "Date" in a standard class by a known "Date" from the same class is not possible!?!?
Only a Class Element.
I could not find a working example of how to search for a Date in this class.
Who do I contact for help???
Thank you.
Hi all, please tell me what's wrong, it's not working for some reason
Question. For 4k.
doubleMarketInfo(
MODE_LOTSIZE
15
Contract size in the base currency of the instrument
do I get it right, this is the value of 1 (one) lot? and divided by the leverage, the value of the lot including the leverage in the first currency of the instrument
MODE_MARGINREQUIRED
32
Amount of free funds needed to open 1 lot to buy
is there an analogue to the last one in 5, if there is, I haven't found it.
MarginFree funds are clear. If we divide them by the value of one lot, we obtain how many lots we can open without leverage, and multiplied by the leverage, how many with leverage. Is it correct or not?
Zy. Is this correct for a 5