Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Twitter !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Experts

MQL4 Implementation of onTrade Event Handler - expert pour MetaTrader 4

Vues:
1387
Note:
(2)
Publié:
2024.04.29 09:33
Mise à jour:
2024.04.29 11:12
onTrade.mq4 (9.23 KB) afficher
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

The code keeps track of orders' tickets in an CArrayInt. Monitoring the changes to the list of tickets in onTimer it triggers these event handlers:

//+------------------------------------------------------------------+
//| Event handler when stop loss is hit                              |
//+------------------------------------------------------------------+
void onStopLoss(ulong ticket);

//+------------------------------------------------------------------+
//| Event handler when take profit is hit                            |
//+------------------------------------------------------------------+
void onTakeProfit(ulong ticket);

//+------------------------------------------------------------------+
//| Event handler when a new order is opened                         |
//+------------------------------------------------------------------+
void onTradeEntry(ulong ticket);

//+------------------------------------------------------------------+
//| Event handler when an order is closed(removed)                   |
//+------------------------------------------------------------------+
void onTradeExit(ulong ticket);

note: Not all features of the MQL5 onTradeTransaction handler has been implemented here. It is just a basic approach.

In the screenshot below you can see the output log for the EA:



Classic and Virtual Trailing Classic and Virtual Trailing

Classic & Virtual Trailing for MT4

Virtual SL TP Pending with SL Trailing for Symbol Chart Virtual SL TP Pending with SL Trailing for Symbol Chart

Virtual SL TP Pending with SL Trailing for Symbol Chart

RSI with channels RSI with channels

standart RSI with dynamic levels

Adaptive SMA Adaptive SMA

improved version of the standard Simple moving average indicator with a lower delay based on: https://www.mql5.com/en/code/30844 (author: https://www.mql5.com/en/users/mladen)