Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1381

 
Vitaly Muzichenko #:

It depends on the overlapping sequence, the last one on top

Define buffer withDRAW_FILLING first

Surprisingly, it worked! I thought this trick was only for the buffers of one indicator, but it turns out to be the same for all.

Thank you!

 
Vitaly Muzichenko #:

Thank you very much, I will try

 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 

Optimisation:

"All ticks" and"Every tick based on real ticks" are the same thing? Which is more credible, if the test has been running since 2012


In the first case the terminal writes "96% history quality", in the second "26% real ticks".

 
Ivan Butko #:

Optimisation:

"All ticks" and"Every tick based on real ticks" are the same thing? Which is more credible, if the test has been running since 2012


In the first case the terminal writes "96% history quality", in the second "26% real ticks".

Read the logs - and you will see from which year the real ticks are. As a rule there are real ticks for the last three years.

 
Vladimir Karputov #:

Read the logs - and you will see from which year the real ticks have been going on. There are usually real ticks for the last three years.

I see, so the real ticks are better, even though it says 26% vs 96%. The last number looks nicer)

Can you also tell me how to select the last tick in the history? Or the last trade. I need to know how it closed: on stop or not.

Trying something, not working.

    int Last_deal_ticket = 0;
    for(int cnt=PositionsTotal()-1;cnt>=0;cnt--)
      {
        if(PositionSelectByTicket(PositionGetTicket(cnt)))
        if(PositionGetSymbol(cnt)==Symbol() && PositionGetInteger(POSITION_MAGIC)==Magic_number)
        Last_deal_ticket=PositionSelectByTicket(PositionGetTicket(cnt));
      }
    // потом, когда закроется, будет висеть с этим тикетом в истории
    // обращаемся к истории
    HistorySelectByPosition(Last_deal_ticket);
    if (HistoryDealGetString(Last_deal_ticket, (ENUM_DEAL_PROPERTY_STRING)DEAL_REASON)==DEAL_REASON_SL......... )


 
Ivan Butko #:

Got it, so the real ticks are better, even though it says 26% vs 96%. The latter number looks prettier)

No, you don't get it.

1. Real ticks do give the real picture when tested.

2. But, you have to use real ticks head on - you have to look at the logs to see from which date there are real ticks. Otherwise, in your case from 2012 to (roughly 2018) go "all ticks" and only then go "every tick based on real ticks.

3. Insert the code RIGHTLY: First the button Code and then insert the code in the pop-up window!!!

 
Vladimir Karputov #:

No, you don't understand.

1. Real tics do give the real picture when tested.

2. But, you have to use real ticks head on - you have to look at the logs to see from which date there are real ticks. Otherwise, in your case from 2012 to (roughly 2018) go "all ticks", and only then go "every tick based on real ticks.

3. Insert the code RIGHTLY: FIRST the button and then insert the code in the popup!!!

Got it, thanks

 
Ivan Butko #:


Can you tell me how to select the last ticket in the history? Or the last trade. I need to know how it closed: by stop or not.

I'm trying something, I can't.

I have sort of grabbed the last trade in the history and tried to check how it was closed

Print("Last deal close = ", HistoryDealGetInteger(Last_deal_ticket,DEAL_REASON)); 

Log

Last deal close = 3


I looked at the documentation and there

Identifier

Description

DEAL_REASON_CLIENT

Deal was executed as a result of an order triggered from the desktop terminal

DEAL_REASON_MOBILE

Deal was executed as a result of a triggered order placed from the mobile application

DEAL_REASON_WEB

Deal is executed as a result of an order placed from the web platform

DEAL_REASON_EXPERT

The trade is executed as a result of a triggered order placed from the MQL5 program - Expert Advisor or script

DEAL_REASON_SL

The deal was executed as a result of a Stop Loss order triggering


First 5 lines.

I do not understand what it means: if we count from 1, then 3 isDEAL_REASON_WEB, which is wrong. If from zero, thenDEAL_REASON_EXPERT. But, then I don't understand now how to know in which trade the stop loss occurred.

Please help.

 
Ivan Butko #:

Seems to have captured the last transaction in the history, tried to see how it closed

Log

Last_deal_ticket = 3


Looked at the documentation, there

ID

Description

DEAL_REASON_CLIENT

Deal was executed as a result of a triggered order placed from the desktop terminal

DEAL_REASON_MOBILE

Deal was executed as a result of a triggered order placed from the mobile application

DEAL_REASON_WEB

Deal was executed as a result of an order placed from the web platform

DEAL_REASON_EXPERT

The trade is executed as a result of a triggered order placed from the MQL5 program - Expert Advisor or script

DEAL_REASON_SL

The deal was executed as a result of a Stop Loss order triggering


First 5 lines.

I do not understand what it means: if we count from 1, then 3 isDEAL_REASON_WEB, which is wrong. If from zero, thenDEAL_REASON_EXPERT. But, then I don't understand now how to know in which trade the stop loss occurred.

Please help.

You are using the ENUM_DEAL_REASON enumeration. You don't have to compare an enum with any digits, you have to compare it with an enum. Here's an example that accesses the trade history (though in OnTradeTransaction) and detects triggering of Stop Loss and Take Profit:

Example: tracking the triggering of Stop Loss or Take Profit

How to start with MQL5
How to start with MQL5
  • 2020.09.17
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
Reason: