
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
What I propose is
OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES);
{
max = MathMax(max,OrderProfit());
min = MathMin(min,OrderProfit());
}.
I'm having some ideas using the:
And than make a iHigh() and iLow() for know the maximum and minimum...
What do you say?
.
And than make a iHigh() and iLow() for know the maximum and minimum...
You need OpenBar, Highest and High[] (or iHigh()). Then you could use (ignoring Commissions and Swap:)
double dvpl = DeltaValuePerLot(), oop = OpenOrderPrice(), ls = OrderLotSize(), profitAtHH = (HH-OOP) * ls*dvpl;
See my codeLike this???
I belive (in my very humble opinion!!) that this code:
--> Select my short position by it's MAGIC_NUMBER (I've 1 Magic for short positions and other for long positions).
--> Discovers it's Profit and compare it with the previous
--> If the profit it's bigger than it keeps that value.
The problem I see is when that order is closed and another one opens. The Max_Profit_Short will only change when the profit is bigger than the previous.
I'm I wrong?
Thanks a lot for the help!!! :)
.
Hi strutch
Book (https://book.mql4.com//) on Array ( https://book.mql4.com/variables/arrays )
:D
Like this???
I belive (in my very humble opinion!!) that this code:
1. --> Select my short position by it's MAGIC_NUMBER (I've 1 Magic for short positions and other for long positions).
2. --> Discovers it's Profit and compare it with the previous
3. --> If the profit it's bigger than it keeps that value.
4. The problem I see is when that order is closed and another one opens. The Max_Profit_Short will only change when the profit is bigger than the previous.
I'm I wrong?
Thanks a lot for the help!!! :)
1. Why ? what is wrong with using OrderType() ?
2. What is max ?
3. If the profit is bigger than max
4. When an order is closed and a new one opens reset Max_Profit_Short to 0.0
.
1 . Because to analyse the shorts and longs separated I thought that would be a nice thing to do...
2 - Yes.. My mistake... I want to write:
3 - Answerd in 2.... :)
4 - Because I'm too newbie I will have to think in a solution to that...
One problem closed opens other!!! That's the newbie life...
Hi deVries,
I'm learning MQL4 language but I din't learn yet the use of arrays in Expert Advisors (I couldn't find nothing about arrays like the codeguru's course..).
That's why I'm stucked in this problem.. :(
WHRoeder code help me to make a cicle than runs all orders and select the one I want (by it's MagicNumber). But I don't know how to find that order Maximum Profit! : (
Any ideas?
.
Why do you think you need an array to do this ??
Come on, this is no attempt yours to make it....
You have done nothing, you are here only asking in the hope someone is gonna make it
Hint
.
for every trade
Profit = OrderProfit() + OrderCommission() + OrderSwap();
So total will be if you sum it Profit = ........ + OrderProfit() + OrderCommission() + OrderSwap();
And before you begin the loop you have to set Profit to zero..
So for you to work on..... then you can ask again
.
deVries, I'm not the lazy guy you are thinking! I simply didn't know how to start...
Now that you gave me the ideas and here it is... My atempt to make the code.
I've no time to test it because I've got to sleep!!!
Tomorow I'll try to insert this "blocks" in my EA to see the results..
Once again, Thank you for your help guys! :)
.
deVries, I'm not the lazy guy you are thinking! I simply didn't know how to start...
Now that you gave me the ideas and here it is... My atempt to make the code.
I've no time to test it because I've got to sleep!!!
Tomorow I'll try to insert this "blocks" in my EA to see the results..
Once again, Thank you for your help guys! :)