[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 47
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
If you know the function for calculating the total balance of loss of CLOSED positions by SL and the total balance of OPEN profitable trades, please write.
Loss balance calculation should start from the last maximum deposit value
Your question is somewhat similar to the previous one, so I tweaked the function from the previous answer a bit. I confess I have not tested it, but it should work. The variables profit and loss declared on global level should show the total profit and loss respectively for the closed positions.
If you need to do this for open orders as well, add a second for loop for selecting them not in history, but according to the OrdersTotal() criterion: for(int n=1; n<=OrdersTotal(); n++)
And add the values obtained to the same variables profit and loss .
For example, I need to know if a pending buy limit has been triggered and if it has, at what price, and then set a new one.
How do I know if an order has triggered a trailing stop and place new orders when the trailing stop has been triggered?
If closed, do you need to know if it just closed? Or did it close with a StopLoss? (It may close at TakeProfit and OrderClose() or OrderCloseBy())
Here is my new bar control function:
where, i_trading_TF is a variable declared globally external. Thus, when I set my Expert Advisor on a chart, I can set the value of this variable in the pop-up window and thus set the timeframe of the bar opening at which I want to control.
I have seen a similar function in one EA but with a formal parameter in the function header. Here it is:
The time frame is passed through the function parameter. However, ifi_trading_TF variableis declared on the global level, I don't think it makes sense to pass it via a formal parameter since its visibility is not limited.
Please comment on this point.
The first option works for me too, but it's strange that some programmers have a habit of stuffing with formal parameters even those functions where I would not do it myself.
On every tick, monitor the presence of an order with OP_BUYLIMIT type using OrderType() function, when this type disappears, it means that the order has opened and become OP_BUY type. All 6 types are listedhere. Using the OrderOpenPrice() function, you can find out at what price the order was opened.
Here is my new bar control function:
where, i_trading_TF is a variable declared globally external. Thus, when I set my Expert Advisor on a chart, I can set the value of this variable in the pop-up window and thus set the timeframe of the bar opening at which I want to control.
I have seen a similar function in one Expert Advisor but with a formal parameter in the function header. It goes like this:
The time frame is passed through the function parameter. However, ifi_trading_TF variableis declared on the global level, I don't think it makes sense to pass it via a formal parameter since its visibility is not limited.
Please comment on this point.
The first option works for me too, but it's strange that some programmers have a habit of stuffing with formal parameters even those functions where I would not do it myself.
It makes sense if the EA analyzes several frames and a new bar must be formed at every frame.
That's not all, let's add the name of the instrument to the transferred parameters
and analyse the fact of a new bar forming, any instrument, period.Not necessarily. It can also be manually killed. Rather, you need to remember the ticket of the pending order; as soon as a pending order with that ticket is found missing and a market position with the same ticket appears, then yes, it's triggered...
It makes sense if the EA analyses several frames and each frame needs the fact of forming a new bar.
That's not all, let's add the name of the instrument to the parameters
and analyse the fact of a new bar forming, any symbol, period.Do you think it is appropriate to "involve" a symbol in the "mechanism for finding a new bar"??? :)))
It would be interesting to make a universal control of the new bar. By the way - everything is there for that
It would be interesting to do universal control of the new bar. By the way - everything is there for that