Hi My friend , Vladimir Karputov.
In this program ,What is the role of this function ?
void OnTradeTransaction(const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result);
Hi My friend , Vladimir Karputov.
In this program ,What is the role of this function ?
void OnTradeTransaction(const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result);
A little help: OnTradeTransaction.
In this code, we catch the inputs and outputs.
//+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ void OnTradeTransaction(const MqlTradeTransaction &trans, const MqlTradeRequest &request, const MqlTradeResult &result) { //--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- if transaction is result of addition of the transaction in history if(type==TRADE_TRANSACTION_DEAL_ADD) { long deal_entry =0; long deal_type =0; double deal_price =0.0; double deal_profit =0.0; double deal_volume =0.0; string deal_symbol =""; long deal_magic =0; if(HistoryDealSelect(trans.deal)) { deal_entry=HistoryDealGetInteger(trans.deal,DEAL_ENTRY); deal_type=HistoryDealGetInteger(trans.deal,DEAL_TYPE); deal_price=HistoryDealGetDouble(trans.deal,DEAL_PRICE); deal_profit=HistoryDealGetDouble(trans.deal,DEAL_PROFIT); deal_volume=HistoryDealGetDouble(trans.deal,DEAL_VOLUME); deal_symbol=HistoryDealGetString(trans.deal,DEAL_SYMBOL); deal_magic=HistoryDealGetInteger(trans.deal,DEAL_MAGIC); } else return; if(deal_symbol==Symbol() && deal_magic==m_magic) if(deal_entry==DEAL_ENTRY_IN) { if(deal_type==DEAL_TYPE_BUY) { LongTrade=true; // true -> last open trade is Buy ShortTrade=false; // true -> last open trade is Sell LastOpenBuyPrice=deal_price; // last open "Buy" price } if(deal_type==DEAL_TYPE_SELL) { LongTrade=false; // true -> last open trade is Buy ShortTrade=true; // true -> last open trade is Sell LastOpenSellPrice=deal_price; // last open "Sell" price } } if(deal_entry==DEAL_ENTRY_OUT) { if(deal_type==DEAL_TYPE_BUY) // close the "Sell" positions { ShortTrade=false; LastOpenSellPrice=0.0; } if(deal_type==DEAL_TYPE_SELL) // close the "Buy" positions { LongTrade=false; LastOpenBuyPrice=0.0; } } } }
And depending on the type of transaction, we assign variable values or zero the variables.
Hello,
I tested this in demo account and it works but when i tested it in live account, it doesn't seem to be triggered. Do i have to change anything in the live account?
In demo account, auto trading happens while in live account, auto trading is not triggered.
Hello,
I tested this in demo account and it works but when i tested it in live account, it doesn't seem to be triggered. Do i have to change anything in the live account?
Please attach the log files from the terminal tabs: the Experts tab and the Journal tab.
Hi, Viktor,
I have the same problem,
It trades very well on the demo, but when I switched to real, on the same MetaTrader, the same conditions, it didn't work.
Can you help pls?
this is MT5 code ....
And this is error message......
2018.11.28 11:03:58.382 Experts automated trading is enabled
2018.11.28 11:06:02.391 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:06:02.391 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
2018.11.28 11:07:02.423 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:07:02.424 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
2018.11.28 11:10:02.234 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:10:02.234 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
Hi, Viktor,
I have the same problem,
It trades very well on the demo, but when I switched to real, on the same MetaTrader, the same conditions, it didn't work.
Can you help pls?
this is MT5 code ....
And this is error message......
2018.11.28 11:03:58.382 Experts automated trading is enabled
2018.11.28 11:06:02.391 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:06:02.391 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
2018.11.28 11:07:02.423 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:07:02.424 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
2018.11.28 11:10:02.234 Angry Bird (Scalping) (EURUSD,M1) CTrade::OrderSend: market sell 0.01 EURUSD [trade disabled]
2018.11.28 11:10:02.234 Angry Bird (Scalping) (EURUSD,M1) Sell -> false. Result Retcode: 10017, description of result: trade disabled, ticket of deal: 0
Please, read the help: How to Control Expert Advisor Trading

- www.metatrader5.com
Over here, I have a major loss in the demo account, when the EA sets a lot of orders in the market with no stop loss. The losses then add up to about 40k, before the positions are sold.
As you are using
#include <Trade\SymbolInfo.mqh>
I would like to suggest:
m_symbol.NormalizePrice(Stopper)
Anywhere you want to have correct prices for any symbol.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Angry Bird (Scalping):
Author: Vladimir Karputov