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
Market closed!
#1 - I never call Button Object by OnTick(), Start(), so is it normal?
#2 - Can I apply to Button Object 'ANCHOR_RIGHT_UPPER'?
#3 - So, I still need help for my this concern #145, please.
Thanks!
#1 - I never call Button Object by OnTick(), Start(), so is it normal?
Yes
#2 - Can I apply to Button Object 'ANCHOR_RIGHT_UPPER'?
No, the anchor point is fixed to ANCHOR_LEFT_UPPER
#3 - So, I still need help for my this concern #145, please.
Yes, you are correct - EventSetMillisecondTimer(250)
Yes
No, the anchor point is fixed to ANCHOR_LEFT_UPPER
Yes, you are correct - EventSetMillisecondTimer(250)
#Profit Orders Counting - Open
I just try to get all profitable positions for calculate all in one value.
It gives me separately values.
I really lost my mind. I tried few ways, and researching a lot about it, but no good results.
Please, help me, if it is possible explain a bit more about profit calculation, much appreciate.
I hope I will get good answer soon.
{
double trueprofit = 0;
for ( int i = OrdersTotal() - 1; i >= 0; i-- )
{
if ( ! OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;
if ( closeothers == false && OrderSymbol() != Symbol() ) continue;
trueprofit = OrderProfit() + OrderSwap() + OrderCommission();
if ( trueprofit >= 0 )
{
Print( "Profit: ", trueprofit );
ObjectSetString ( 0, "all profit counting object", OBJPROP_TEXT, DoubleToString( trueprofit, 2 ) );
}
}
//---
return;
}
Thanks in advance.
Your are overwriting the value of trueprofit on each iteration of the loop, rather than adding to the value.
Remember this:
was changed to this:
You need to be clear between what you want to happen on each iteration of the loop (each order) and what you want to happen after the loop (after you have checked all the orders).
Thanks for your quickly reply.
Maybe I am so tired, so sorry. ( Just I can't understand what I could do. )
I need to describe a bit more my concern ( how much I can ).
So, I have 2 functions:
Finally, I would like to this ( my latest comment code ) profit calculate function could calculate both types of Orders " OP_SELL and OP_BUY " just profitable.
Thanks in advance.
how are you trying to show all profitable values in one Label?
Do you mean all added up AcountProfit() or for each separate OrderProfit().
If you need something like this:
Please see this article:
https://www.mql5.com/en/articles/2723
Thanks for your comment.
Sorry for the confusion.
No, I think I need little different from it.
I will try to clarify my issue.
I have 3 positions for EURUSD. Two of them profitable positions, one of them loss position. So I just need to calculate two of them which is they are profitable.
eg: if each of them +1.00 ( 2 profitable positions = +2.00 ) just I need to get all profitable positions value.
I just quick made below tab for helps me what I am trying to say. ( at the below of this comment image file )
( English not my native language - sometimes I struggling with it )
All the best.
// in your orderselect loop put
if(OrderProfit()>0)
{
totalprofit=totalprofit+OrderProfit();
}
#Profit Orders Counting - Closed
{
totalprofit=totalprofit+OrderProfit();
}
I solve my issue after your great example code.
Great man, big thanks!
Your are overwriting the value of trueprofit on each iteration of the loop, rather than adding to the value.
Remember this:
You need to be clear between what you want to happen on each iteration of the loop (each order) and what you want to happen after the loop (after you have checked all the orders).
Just after finished below code script.
Once again I check your comment, then I know you explain it me. But my English prevent to understand it.
All the best to each of you men.
{
double trueprofit = 0;
double totalprofit = 0;
for ( int i = OrdersTotal() - 1; i >= 0; i-- )
{
if ( ! OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;
if ( closeothers != true && OrderSymbol() != Symbol() ) continue;
trueprofit = OrderProfit() + OrderSwap() + OrderCommission();
if ( trueprofit >= 0 )
{
totalprofit += OrderProfit() + OrderSwap() + OrderCommission();
Print( "Profit: ", DoubleToString( totalprofit, 2 ) );
ObjectSetString ( 0, _Checkthisout_name_Label, OBJPROP_TEXT, "Total Profit: " + DoubleToString( totalprofit, 2 ) );
}
}
//---
return;
}
I hope this code script will work good. If something wrong in above code, please let me know.
Thanks for everything.