
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
There is also an organisational issue, if anyone knows how to solve it in the best way - please write it in words, I will put it in code:
in general, how to understand that the order cycle, a new position - PROFIT has started - to take into account the average opening price of the position (clearing changes its value):
to be clear, I can both from the terminal via the keys myself and by a robot with magik....
In general, I need a report point - to calculate the average entry price of the position.
Can I use data from here + for example read time when previous position closed in profit and take a difference with the real server time from there, like if I start a cycle from the terminal - without a robot:
I mean something like this:
like the past position is on the plus side - then the current cycle accounting has already started. and orders - you must already count both entry price and volume to calculate the average entry price of the aggregate position...https://www.mql5.com/ru/articles/211
--------------------------------------------------------------
Of course, ideally it should be closed regardless of the outcome of the previous cycle - profit or loss.
The start - the new one was marked for calculation in the code - the average price of the new current cycle of averages, for example, or fills - it doesn't matter...
Is there anyone ready to calculate the average price of the final position? I'm getting tired of counting and correcting code - the stone flower does not work....:-)
I tried different methods in OnTrade Transaction () - many extra things get into calculation, lots are doubled in result - that's not right:
Events"For example, when sending a market buy order, it is processed, an appropriate buy order is created for the account, the order is executed, removed from the list of the open ones, added to the orders history, then an appropriate deal is added to the history and a new position is created. All these actions are trade transactions
"
This is via On Trade Transaction ()
With this kind of f-i - lots in the average position entry price calculation (netting) is not counted correctly.
It may be easier to do it via On Trade.
I'm looking at it through On Trade () right now: everything is explained here, we just have to insert calculation into the code and that's all... Basically.
https://www.mql5.com/ru/articles/40
Basically, here's the design - if there is an increased position, then the average price will be calculated. When the position is closed, all of the intermediate variables must be zeroed out. Basically, everything is elementary there.
The task is to exclude changes of the position opening price during clearing (when it becomes equal to the symbol price at the time of clearing).
I.e. to read it in the code.
No one has a ready design for calculating the average price of a final position? I'm getting tired of counting and correcting code - it doesn't work....:-)
Here's a piece of my old, but still "fighting" code:
Here's a piece of my old but still 'actionable' code:
О!!! Thanks so much for such a quick response - I'll take it up for review and editing.
Note - "st" (there is quite a big structure, including trails and statistics) is exactly the "state" of the robot - what is dumped to disk after change (and when deinit) and loaded when yinit.
And yes, most likely st.Price and st.PriceAvr aren't really needed here, one is enough, but the code is old, more than 5 years, and all my "combat" robots are tied to it, so "first rule of aviation mechanics - don't mess with the working mechanism".
the result of clearing is the transfer of all positions to the current price, i.e. to the average price inside the spread
who cares about this exchange? ...
Note - "st" (there is quite a big structure, including trails and statistics) is exactly the "state" of the robot - what is dumped to disk after change (and when deinit) and loaded when yinit.
And yes, most likely st.Price and st.PriceAvr aren't really needed here, one is enough, but the code is old, more than 5 years, and all my "combat" robots are tied to it, so "first rule of aviation mechanics - don't mess with the working mechanism".
the result of clearing is the transfer of all positions to the current price, i.e. to the average price inside the spread
who cares about this exchange? ...
the result of clearing is the transfer of all positions to the current price, i.e. to the average price inside the spread
Who cares about the exchange? ...
I only trade on the exchange.
I only trade on the stock exchange.
and I only trade forex.
I don't know how to trade the stock market.
i've been there, i've been there.
not my thing - re-learn
by the way, why is the average price in the market not the one after clearing?
// or else i would trade there ;)
// but as it turns out they don't give everything in the glass, they hide a bit, i.e. the glass sucks?
I'll post it here as soon as I make the fic.
Everything has been posted in the Exchange Trading section for a long time
https://www.mql5.com/ru/forum/67298/page3#comment_2109451