This code shows position's profit as pips,
But when position is close, it's still shows the last profit! I want it to show "0" after close the position (or shows "SomeTex") . What should I do?
When I change time frame, it change to "0". I want it change to "0" or some text when position was close.
Problem is in PiP Count !
In this function . . .
//========== FUNCTION getOpenOrders void getOpenOrders() { int totalorders = OrdersTotal(); if(totalorders == 0) // add these 5 lines { pipVal = 9999; return; } for(int j=0; j<totalorders;j++) { OrderSelect(j, SELECT_BY_POS, MODE_TRADES); if((OrderType() == OP_BUY || OrderType() == OP_SELL) && OrderSymbol() == Symbol()) { double val=getPipValue(OrderOpenPrice(),OrderType()); pipVal = val; //int val = OrderProfit()/(OrderLots()*10); } } }
in this code . . .
if (pipVal < 0) LabelColor = Red; else if(pipVal == 9999) // add these 5 lines { LabelColor = Black; pipVal = 0; } else LabelColor = Lime;
So when you have no open trades pipVal will be set to 0 and shown in black.
You change it for all position, Now when all position are close, it shows black color, but I need it for current chart. For current chart still the same!
I did change, what about the current chart?
When I close the current chart position and other position is still open, current chart shows the last profit (freez number) until the other position be close or new position be open in current chart!
I did change, what about the current chart?
When I close the current chart position and other position is still open, current chart shows the last profit (freez number) until the other position be close or new position be open in current chart!
If you change it inside the loop and there are no open orders the loop is not executed and pipVal is not changed.
You also have many Object where you are not checking if they exists before you try to create them . . .
I think I can't explain what I need!!
If you check the indicator, It shows open position's profit as pip.
When a position is open it works so good, but after close position ( with +/- profit) still we can see the last profit of current chart in the chart (freezing), it goes to change when:
1. New position in current chart open.
2. Change the chart time frame.
3. All position are close ( when I add new code line RaptorUk made it).
What I need ?
I need change profit too "0" (zero) or "some text" after close position in current chart.
What I need ?
I need change profit too "0" (zero) or "some text" after close position in current chart.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This code shows position's profit as pips,
But when position is close, it's still shows the last profit! I want it to show "0" after close the position (or shows "SomeTex") . What should I do?
When I change time frame, it change to "0". I want it change to "0" or some text when position was close.