Forum

Pending order (with 2-bar expiry) triggered, but not expired (while others before it do expire)

Greetings, I am struggling to figure out what's happening in this case. Scenario: MQL5 EA Pending buy order with expiry (2 bars) is placed successfully (like many others before it during a back-test which work just fine, ie, expiries work, see history image below) The pending order is triggered

m_order.Select(trans.order) works, but m_deal.Ticket(trans.deal) does not (without first HistorySelect() - HistoryDealSelect())

Greets, Hope someone can shed some light on this question. I must either be missing something, or it just is what it is. I am using OnTradeTransaction() to deal with events. All good, but I'm trying to use the classes (such as CDealInfo , etc) to be as MQL5 idiomatic as possible. The following works

Indicator not displaying horizontal lines (ObjectCreate/ObjectSetInteger)

Greets, Would appreciate any comment on where I might be going wrong here. Creating an indicator works as expected. However, I would like to parameterize the two horizontal levels (eg, 80% and 20%) instead of using the usual #property indicator_level1 lines which are hard coded). Here's the sample

CDealInfo -> Magic() not returning magic number on profitable deal

Greets, This has been working for a while now, but today I noticed it's not working as expected. Not sure what's changed (maybe nothing has changed and this has never worked). I basically want to trigger some code when a deal is in profit/loss. It works when the deal is in loss (ie, hits the SL)

AccountInfoDouble(ACCOUNT_MARGIN_LEVEL) always returns 0.0

Greets, I'd like to check the margin level percentage before placing a trade, but AccountInfoDouble(ACCOUNT_MARGIN_LEVEL) always returns 0.0. I've read the article here https://www.mql5.com/en/forum/228052 but it doesn't solve my problem. As a test, whether I'm calling in OnInit() or OnTick()

Backtesting and margin level %

Greetings, When performing backtesting mt5, in the results tab you are given the lowest margin level % it reaches. My broker does a margin call at 50%, so I’m trying to get clarity: given a leverage of 1:100 or 1:500 or whatever, is that margin level % in the backtest results a good guide wrt the

Margin level % in MT5 backtest results - what would constitute a margin call?

Greetings, Trying to understand the meaning behind the number in the backtest results for Margin Level %. At what level would it be considered a 'bad thing", ie, being margin called in possible future live trading? For example, some of my backtests show this level at 419%, other times it is 1765%. I

Detecting the last profit/loss in transaction history reliably for a given magic number

Hi all, I'm trying to detect the last profit/loss in the transaction history (which I think I've got right), but something unexpected is happening, hopefully someone will have an idea. Here's the snippet: void OnTradeTransaction ( const MqlTradeTransaction & trans, const MqlTradeRequest &

Strategy tester using EA on Daily bars - always "market closed"

Greets, I've been trying my hand at writing MQL5 EAs for a while now and everything works as expected. I've always used the strategy tester on intra-day timeframes, but recently decided to give the Daily TF a try. Problem is the strategy tester always fails to place any test trades because the

CopyBuffer() on iVolume() handle fails with 4807 error (invalid handle)

Greets, I've been googling around for a solution to this to no avail. Hopefully someone else has experienced this and knows what the solution is. So CopyBuffer() expects an int handle as the first argument. This works fine for most indicators, except iVolume() which returns a long. Typecasting