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
I recommend to avoid this design
as processing of the previous tick may take enough time to miss the arrival of the first tick of the new bar.
respectively, it is possible to miss the opening.
It is better to bind to the time of bar opening, but for this you need to save the previous time of the zero bar for example, to compare it with the current time of the zero bar.
If it is the same, there is no new bar
If it is different, then at least a new (next) bar is opened, after which we initialise the stored time of the zero bar with the current time of the zero bar.
This construction is more reliable.
Address this in a future article:
As far as I can tell MT5 only supports *1* (one) server-side s/l and t/p order *per instrument* (not per trade) and no OCO orders (OCO orders can be used to simulate per-trade s/l and t/p orders, but there's a race condition there too). Unless the above is addressed I wouldn't commit any more than $100 to trading via MT5 (simplistic single-order single-timeframe single-direction MA cross type EAs). And I'm not even sure about the $100.
I recommend to avoid this design
as processing of the previous tick may take enough time to miss the arrival of the first tick of the new bar.
respectively, it is possible to miss the opening.
It is better to bind to the time of bar opening, but for this you need to save the previous time of the zero bar for example, to compare it with the current time of the zero bar.
If it is the same, there is no new bar
If it is different, then at least a new (next) bar is opened, after which we initialise the stored time of the zero bar with the current time of the zero bar.
This design is more reliable.
I have done it this way:
Compiles but debugger fails.
loading of C:\Program Files\MetaTrader 5\MQL5\Experts\Examples\eMyEA.ex5 failed
New article The Prototype of Trade Robot is published:
Author: Алексей Сергеев
Thanks for the great article! I'm a newbie but I have a question about the code.
In the function void CExpertAdvisor::TrailingPosition(long dir,int TS), there is one line:
sl=NormalSL(dir,apr,apr,TS,StopLvl); // calculate Stop Loss
Should we use apr for both the second and the third argument when calling NormalSL? I thought it should be:
sl=NormalSL(dir,op,apr,TS,StopLvl);
since the second argument should be the bid/ask price for "specified" direction (i.e., the variable op) rather than the "reverse" direction (i.e., the variable apr).
Thanks!
In the function void CExpertAdvisor::TrailingPosition(long dir,int TS), there is one line:sl=NormalSL(dir,apr,apr,TS,StopLvl); // calculate Stop Loss
Should we use apr for both the second and the third argument when calling NormalSL? I thought it should be:
sl=NormalSL(dir,op,apr,TS,StopLvl);
no.
the second and third argument must be apr.
because the calculation of tral is derived from the price at which the position will be closed. Bid for the Buy and Ask for Sell. function is correct.
since the second argument should be the bid/ask price for "specified" direction (i.e., the variable op) rather than the "reverse" direction (i.e., the variable apr).
no.
the second and third argument must be apr.
because the calculation of tral is derived from the price at which the position will be closed. Bid for the Buy and Ask for Sell. function is correct.
should be calculated from the "reverse" direction. In this case, apr.Thanks for the quick reply! I thought I must be wrong.
Can I also ask in the function
why we have a "10" between "dist" and "m_smbinf.TickValue()" in the return value? I guess "dist" is the stop loss (in terms of pips), and "m_smbinf.TickValue()" is the US dollar value per pip per lot for the currency pair. So I'm not sure why we multiply another "10" in between them.
Thanks!
Very useful article. Thanks a lot!