Stop-Auslöser im OnTradeTransaction-Backtest erkennen - Seite 3

 
angevoyageur:

Ich habe es überprüft. Wenn ein SL/TP ausgelöst wird, haben Sie diese Transaktion:

  1. TRADE_TRANSACTION_POSITION mit gesetztem SL und TP (aber noch keinem Geschäft), dann
  2. TRADE_TRANSACTION_DEAL_ADD

Wenn ich short gehe - von einer jungfräulichen Position aus, erhalte ich 3 Transaktionen:

A Eintrag )

20130507 21:52:28:943 entry short at 1.31060 time=2013.01.10 11:43

20130507 21:52:28:943 symbol=EURUSD price=1.3106000 volume=0.01 sl=1.3119000 tp=1.3088000 order=2 deal=2 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00

20130507 21:52:28:943 symbol=EURUSD price=1.3106000 volume=0.01 sl=1.3119000 tp=1.3088000 order=2 deal=0 entry-type=IN trans-type=ORDER_DELETE order_type=SELL deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00

20130507 21:52:28:943 symbol=EURUSD price=1.3106000 volume=0.00 sl=1.3119000 tp=1.3088000 order=2 deal=0 entry-type=IN trans-type=HISTORY_ADD order_type=SELL deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00

Sobald der Stop Loss ausgelöst wurde, erhalte ich

B Ausstieg )

20130507 21:52:28:945 symbol=EURUSD price=1.3119000 volume=0.01 sl=0.0000000 tp=0.0000000 order=3 deal=3 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00

KeineTRADE_TRANSACTION_POSITION. Ich denke, Sie können es hier nicht verwenden.

Zusammenfassung:

Ein Short wird eröffnet, die erste Transaktion ist

entry-type=IN trans-type=DEAL_ADD order_type=BUYsl=1.3119000 tp=1.3088000

Short geschlossen, durch Stop oder Target, erste reflektierte Transaktion

entry-type=IN trans-type=DEAL_ADD order_type=BUY sl=0.0 tp=0.0

Dies ist verwirrend. Es sollte lauten:

open short:

entry-type=IN trans-type=DEAL_ADD order_type=SELLsl=1.3119000 tp=1.3088000

Short schließen:

entry-type=OUT trans-type=DEAL_ADD order_type=BUY sl=0.0 tp=0. 0

angevoyageur:

Ich habe es überprüft. Wenn ein SL/TP ausgelöst wird, haben Sie diese Transaktion:

  1. TRADE_TRANSACTION_POSITION mit gesetztem SL und TP (aber noch keinem Geschäft), dann
  2. TRADE_TRANSACTION_DEAL_ADD
 
chinaski:

Wenn ich von einer jungfräulichen Position aus short gehe, erhalte ich 3 Transaktionen:

A Eintrag )

Sobald der Stop Loss ausgelöst wurde, erhalte ich

B Ausstieg )

KeineTRADE_TRANSACTION_POSITION.Ich denke, Sie können es hier nicht verwenden.

...

Sie vermissen einige Transaktionen, ich weiß nicht warum. Weil Backtesting ?

 

Kleine Abschweifung, anstelle von :

ORDER_TYPE_to_string(t.order_type)

können Sie verwenden:

EnumToString(t.order_type)


 
angevoyageur:

Kleine Abschweifung, anstelle von :

können Sie verwenden:


Vielen Dank für EnumToString, das ist viel schlauer zu benutzen.

Ja, meine Sorge gilt der Transaktion im Backtest. Aber um es so realistisch wie möglich zu machen, sollte die Transaktion die gleiche sein wie im Live-Handel.

TRADE_TRANSACTION_POSITION ist nicht mit einem Geschäft verbunden, wie Sie bereits erwähnt haben. Ich vermute, es zeigt zum Beispiel an, wann Sie etwas Geld auf Ihrem Konto bewegt haben.

 
chinaski:

...

Das Problem scheint zu sein, dass einige Transaktionen beim Backtesting nicht verfügbar sind. Ein Fehler oder eine Einschränkung des Backtestings. Wenn ich einen Forward-Test durchführe, habe ich eine TRADE_TRANSACTION_POSITION, wenn SL/TP ausgelöst wird.

2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_ORDER_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=ORDER_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_ORDER_DELETE
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=ORDER_DELETE order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_HISTORY_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.00 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=HISTORY_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_POSITION
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3173500 volume=0.01 sl=1.3174200 tp=1.3170100 order=0 deal=0 entry-type=IN trans-type=POSITION order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_DEAL_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=16655372 entry-type=OUT trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.34

Get in touch with developers using Service Desk!
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
 
angevoyageur:

Das Problem scheint zu sein, dass einige Transaktionen beim Backtesting nicht verfügbar sind. Ein Fehler oder eine Einschränkung des Backtestings. Wenn auf einem Forward-Test laufen, habe ich eine TRADE_TRANSACTION_POSITION, wenn SL/TP ausgelöst wird.

2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_ORDER_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=ORDER_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_ORDER_DELETE
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=ORDER_DELETE order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_HISTORY_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.00 sl=0.0000000 tp=0.0000000 order=19683612 deal=0 entry-type=IN trans-type=HISTORY_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_POSITION
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3173500 volume=0.01 sl=1.3174200 tp=1.3170100 order=0 deal=0 entry-type=IN trans-type=POSITION order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    TRADE_TRANSACTION_DEAL_ADD
2013.05.08 19:20:29    tc_ea_trans (EURUSD,M1)    trans=symbol=EURUSD price=1.3170100 volume=0.01 sl=0.0000000 tp=0.0000000 order=19683612 deal=16655372 entry-type=OUT trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.34

Okay, vielen Dank für diese Information. Ich weiß also, dass ich dies in meine Überlegungen einbeziehen muss.
 

Hallo angevoyageur,

ich habe immer noch das Problem, dass ich im Backtest den Ausführungskurs eines an eine Position angehängten Stops oder Verlustes bekomme. Ich weiß bis jetzt nicht, wie es sich unter Live-Bedingungen verhält.

Dies ist aus dem Backtest-Log:

KP      0       23:18:29        Core 1  2010.05.11 11:00:00   instant buy 0.01 EURUSD at 1.26882 (1.26871 / 1.26882 / 1.26871)
EM      0       23:18:29        Core 1  2010.05.11 11:00:00   deal #2  buy 0.01 EURUSD at 1.26882 done (based on order #2)
 MG      0       23:18:29        Core 1  2010.05.11 11:00:00   deal performed [#2  buy 0.01 EURUSD at 1.26882]
RI      0       23:18:29        Core 1  2010.05.11 11:00:00   order performed buy 0.01 at 1.26882 [#2  buy 0.01 EURUSD at 1.26882]
JS      0       23:18:29        Core 1  2010.05.11 11:00:00   CTrade::OrderSend: instant buy 0.01 EURUSD at 1.26882 [done at 1.26882]
LP      0       23:18:29        Core 1  2010.05.11 11:00:00   position modified [buy 0.01 EURUSD 1.26882 sl: 1.26809 tp: 1.27028]
LM      0       23:18:29        Core 1  2010.05.11 11:00:00   CTrade::OrderSend: modify EURUSD (sl: 1.26809, tp: 1.27028) [done]
LR      0       23:18:29        Core 1  2010.05.11 11:00:00   trans=symbol=EURUSD price=1.2688200 volume=0.01 sl=0.0000000 tp=0.0000000 order=2 deal=2 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000
GG      0       23:18:29        Core 1  2010.05.11 11:18:40   take profit triggered buy 0.01 EURUSD 1.26882 sl: 1.26809 tp: 1.27028 [#3  sell 0.01 EURUSD at 1.27028]
MD      0       23:18:29        Core 1  2010.05.11 11:18:40   deal #3  sell 0.01 EURUSD at 1.27028 done (based on order #3)
 PI      0       23:18:29        Core 1  2010.05.11 11:18:40   deal performed [#3  sell 0.01 EURUSD at 1.27028]
NO      0       23:18:29        Core 1  2010.05.11 11:18:40   order performed sell 0.01 at 1.27028 [#3  sell 0.01 EURUSD at 1.27028]
RS      0       23:18:29        Core 1  2010.05.11 11:18:40   trans=symbol=EURUSD price=1.2702800 volume=0.01 sl=0.0000000 tp=0.0000000 order=3 deal=3 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000
JM      0       23:18:29        Core 1  2010.05.20 09:00:00   ut =3.00 candle=o=1.24130 c=1.24170 h=1.24360 l=1.24100 b=39 uw=190 lw=29
FK      0       23:18:29        Core 1  2010.05.20 09:00:00   instant sell 0.01 EURUSD at 1.24180 (1.24180 / 1.24195 / 1.24180)
MG      0       23:18:29        Core 1  2010.05.20 09:00:00   deal #4  sell 0.01 EURUSD at 1.24180 done (based on order #4)
 IG      0       23:18:29        Core 1  2010.05.20 09:00:00   deal performed [#4  sell 0.01 EURUSD at 1.24180]
CN      0       23:18:29        Core 1  2010.05.20 09:00:00   order performed sell 0.01 at 1.24180 [#4  sell 0.01 EURUSD at 1.24180]
EO      0       23:18:29        Core 1  2010.05.20 09:00:00   CTrade::OrderSend: instant sell 0.01 EURUSD at 1.24180 [done at 1.24180]
EQ      0       23:18:29        Core 1  2010.05.20 09:00:00   position modified [sell 0.01 EURUSD 1.24180 sl: 1.24253 tp: 1.24034]
DO      0       23:18:29        Core 1  2010.05.20 09:00:00   CTrade::OrderSend: modify EURUSD (sl: 1.24253, tp: 1.24034) [done]
HI      0       23:18:29        Core 1  2010.05.20 09:00:00   trans=symbol=EURUSD price=1.2418000 volume=0.01 sl=0.0000000 tp=0.0000000 order=4 deal=4 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000
JH      0       23:18:29        Core 1  2010.05.20 09:00:40   stop loss triggered sell 0.01 EURUSD 1.24180 sl: 1.24253 tp: 1.24034 [#5  buy 0.01 EURUSD at 1.24253]
HI      0       23:18:29        Core 1  2010.05.20 09:00:40   deal #5  buy 0.01 EURUSD at 1.24253 done (based on order #5)
 MK      0       23:18:29        Core 1  2010.05.20 09:00:40   deal performed [#5  buy 0.01 EURUSD at 1.24253]
NL      0       23:18:29        Core 1  2010.05.20 09:00:40   order performed buy 0.01 at 1.24253 [#5  buy 0.01 EURUSD at 1.24253]
KQ      0       23:18:29        Core 1  2010.05.20 09:00:40   trans=symbol=EURUSD price=1.2425300 volume=0.01 sl=0.0000000 tp=0.0000000 order=5 deal=5 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_BUY type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000
PJ      0       23:18:30        Core 1  2010.08.26 09:08:00   ut =3.83 candle=o=1.27238 c=1.27274 h=1.27448 l=1.27238 b=35 uw=174 lw=0
IH      0       23:18:30        Core 1  2010.08.26 09:08:00   instant sell 0.01 EURUSD at 1.27276 (1.27276 / 1.27287 / 1.27276)
GH      0       23:18:30        Core 1  2010.08.26 09:08:00   deal #6  sell 0.01 EURUSD at 1.27276 done (based on order #6)
 MR      0       23:18:30        Core 1  2010.08.26 09:08:00   deal performed [#6  sell 0.01 EURUSD at 1.27276]
HR      0       23:18:30        Core 1  2010.08.26 09:08:00   order performed sell 0.01 at 1.27276 [#6  sell 0.01 EURUSD at 1.27276]
PR      0       23:18:30        Core 1  2010.08.26 09:08:00   CTrade::OrderSend: instant sell 0.01 EURUSD at 1.27276 [done at 1.27276]
FE      0       23:18:30        Core 1  2010.08.26 09:08:00   position modified [sell 0.01 EURUSD 1.27276 sl: 1.27349 tp: 1.27130]
LK      0       23:18:30        Core 1  2010.08.26 09:08:00   CTrade::OrderSend: modify EURUSD (sl: 1.27349, tp: 1.27130) [done]
NE      0       23:18:30        Core 1  2010.08.26 09:08:00   trans=symbol=EURUSD price=1.2727600 volume=0.01 sl=0.0000000 tp=0.0000000 order=6 deal=6 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000
HM      0       23:18:30        Core 1  2010.08.26 09:08:40   stop loss triggered sell 0.01 EURUSD 1.27276 sl: 1.27349 tp: 1.27130 [#7  buy 0.01 EURUSD at 1.27349]

Wie Sie in der letzten Zeile sehen können, ist der ausgeführte Preis im Protokoll angegeben -> [#7 buy 0.01 EURUSD at 1.27349]

Aber keine Struktur, Transaktion, kein Geschäft und keine Auftragshistorie liefert diesen Preis.

In dieser Zeile wird die Transaktion im Zusammenhang mit dem ausgelösten Stop gelöscht:

NE      0       23:18:30        Core 1  2010.08.26 09:08:00   trans=symbol=EURUSD price=1.2727600 volume=0.01 sl=0.0000000 tp=0.0000000 order=6 deal=6 entry-type=IN trans-type=DEAL_ADD order_type=BUY deal_type=DEAL_TYPE_SELL type_time=0 expiration=1970.01.01 00:00 price_trigger=0.0000000 profit=0.00 order-open=0.000000 order-current=0.000000 deal-price=0.000000

Dies ist der Code der Dump-Funktion:

string dump_MqlTradeTransaction(const MqlTradeTransaction& t)
{
    //CDealInfo deal;
    //deal.Ticket(t.deal);
   if(t.deal > 0)
      HistoryDealSelect(t.deal);
   string msg=StringFormat("symbol=%s price=%.7f volume=%.2f sl=%.7f tp=%.7f order=%d deal=%d entry-type=%s trans-type=%s order_type=%s deal_type=%s type_time=%d expiration=%s price_trigger=%.7f profit=%.2f order-open=%.6f order-current=%.6f deal-price=%.6f"
                           
                           ,t.symbol
                           ,t.price
                           ,t.volume                           
                           ,t.price_sl
                           ,t.price_tp
                           ,t.order
                           ,t.deal           
                                                   ,tc_DEAL_ENTRY_to_string_short((ENUM_DEAL_ENTRY)HistoryDealGetInteger(t.deal,DEAL_ENTRY))                                          
                           ,tc_ENUM_TRADE_TRANSACTION_TYPE_to_string_short((ENUM_TRADE_TRANSACTION_TYPE) t.type)
                           ,tc_ORDER_TYPE_to_string(t.order_type)
                           ,tc_DEAL_TYPE_to_string(t.deal_type)
                           ,t.time_type
                           ,TimeToString(t.time_expiration)                           
                           ,t.price_trigger
                           ,HistoryDealGetDouble(t.deal,DEAL_PROFIT)
                                                        ,HistoryOrderGetDouble(t.order,ORDER_PRICE_OPEN)
                                                        ,HistoryOrderGetDouble(t.order,ORDER_PRICE_CURRENT)
                                                        ,HistoryDealGetDouble(t.deal,DEAL_PRICE)
                           );
                        
    return msg;
}

Ich habe also versucht, den Ausführungspreis aus der Auftrags- und Geschäftshistorie zu ermitteln: kein Ergebnis

 
chinaski:

Hallo angevoyageur,

...
Danke, ich werde gehen, um zu studieren, dass ASAP.
 
angevoyageur:
Danke, ich werde mir das so schnell wie möglich ansehen.

Das ist wirklich schön. Nur keine Eile.

Ich habe jede Transaktion, jede Anfrage und jedes Ergebnis, das an OnTradeTransaction übergeben wird, überprüft.

Der ausgelöste Stop-Loss-Kurs, der im Backtest-Protokoll (das von MetaTrader erstellt wird) erwähnt wird, kann nur als Sl-Kurs gefunden werden, nicht aber als Preis, Abschlusskurs oder Ausführungspreis.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties - Documentation on MQL5
 
chinaski:

Das ist wirklich schön. Nur keine Eile.

Ich habe jede Transaktion, jede Anfrage und jedes Ergebnis, das an OnTradeTransaction übergeben wird, überprüft.

Der ausgelöste Stop-Loss-Kurs, der im Backtest-Protokoll (das von MetaTrader erstellt wird) erwähnt wird, kann nur als Sl-Kurs gefunden werden, nicht aber als Preis, Deal-Kurs oder Ausführungspreis.

Wir sprechen also nur von Backtesting. Ich habe mit meinem eigenen Code getestet und ich erhalte 3 Transaktionen, wenn ein Stop ausgelöst wird:

2013.05.15 10:22:27    Core 1    2013.05.10 16:20:37   Symbol : EURUSD  event : TRADE_TRANSACTION_DEAL_ADD(6)
2013.05.15 10:22:27    Core 1    2013.05.10 16:20:37   Symbol : EURUSD  event : TRADE_TRANSACTION_ORDER_DELETE(2)
2013.05.15 10:22:27    Core 1    2013.05.10 16:20:37   Symbol : EURUSD  event : TRADE_TRANSACTION_HISTORY_ADD(3)

Mit DEAL_ADD erhalte ich den Preis des Geschäfts, also in meinem Fall den SL. Alles scheint mir korrekt zu sein. Ich schlage vor, Sie schicken mir den von Ihnen verwendeten Code, das Backtest-Protokoll (als Datei) und einen Screenshot der Einstellungen des Strategietesters. Dann kann ich genau den gleichen Test wie Ihren durchführen und das Ergebnis analysieren. Sie können mir auch eine PM schicken, wenn Sie möchten.