Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1598

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
just to add, it is NOT GUARANTEED that the terminal has and will give sufficient history.
in the above example there is no reference to history
so it is guaranteed that the result of OrderSelect() is true
UPD: OrderSelect in 4 works very well, tested it once - for market orders the time of access to order properties.... it really is millions of times per second, i don't want to look it up, i think i was arguing with moderator Artem, but it's like they say "all tiptoes differ", if you like it, keep it
Hello, there is a need for data on the drawdown of each transaction.
Can anyone meet a script to collect such statistics and output in the form of a report?
Thank you
Hello, there is a need for data on the drawdown of each transaction.
Can anyone meet a script to collect such statistics and output in the form of a report?
Thanks
for(int i=OrdersTotal()-1;i>=0;i--) {
if (!OrderSelect(i,SELECT_BY_POSITON,MODE_TRADES)) continue;
double prosad=DBL_MIN;
if (OrderType()!=OP_BUY && OrderType!=OP_SELL) continue;
for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) {
double delta=( OrderType()==OP_BUY? OrderOpenPrice()-iLow(OrderSymbol(),PERIOD_M1,j) : iHigh(OrderSymbol(),PERIOD_M1,j)-OrderOpenPrice() );
delta /= MarketInfo(OrderSymbol(),MODE_POINT);
if (delta>prosad) prosad=delta;
}
PrintFormat("Максимальная просадка по ордеру %d = %d пунктов , %f денег",OrderTicket(),(int)(prosad),prosad*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE);
}
it is "handwritten", untested, full of bugs :-) just tweak it to your needs and use it
for(int i=OrdersTotal()-1;i>=0;i--) {
if (!OrderSelect(i,SELECT_BY_POSITON,MODE_TRADES)) continue;
double prosad=DBL_MIN;
if (OrderType()!=OP_BUY && OrderType!=OP_SELL) continue;
for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) {
double delta=( OrderType()==OP_BUY? OrderOpenPrice()-iLow(OrderSymbol(),PERIOD_M1,j) : iHigh(OrderSymbol(),PERIOD_M1,j)-OrderOpenPrice() );
delta /= MarketInfo(OrderSymbol(),MODE_POINT);
if (delta>prosad) prosad=delta;
}
PrintFormat("Максимальная просадка по ордеру %d = %d пунктов , %f денег",OrderTicket(),(int)(prosad),prosad*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE);
}
written "by hand", not checked, full of errors :-) adjust to your needs and use
thanks, I'll try to figure it out!
@Igor Makanu, thank you very much for your answers about sorting orders in the terminal. I'll probably save them as an array of structures and sort it myself. Doubts were mainly because I feared that such actions performed on every tick would have a noticeable negative impact on performance.
So why sort on every tick? Enough only when the number of entries changes or the list changes completely...
in the above example there is no reference to history
so it is guaranteed that the result of OrderSelect() is true
UPD: OrderSelect in 4 works very well, I was testing it once - for market orders the time of access to order properties.... it really is millions of times per second, i don't want to look it up, i think i was arguing with moderator Artem, but as they say "all tip-toes are different", i like it - keep it