I was debating with myself whether this was too basic to bring up but after writing it, I’m glad I did. Referencing scikit-learn’s confusion matrix documentation, it’s not immediately apparent what convention the axes follow. When the confusion_matrix function is called, we get the following output: So which value corresponds to True Negative, True Positive, … Continue reading
Data visualisation with Plotly R library Continue reading
High[x] returns the high price of the period at shift x. https://docs.mql4.com/predefined/high iHighest() returns the shift of where the highest price is observed for the defined periods. https://docs.mql4.com/series/ihighest Combine them to obtain the highest price for the defined periods: double highestPrice = High[iHighest(Symbol(), 0, MODE_HIGH, 10, 1)]; In this example, the last parameter being “1” … Continue reading
To obtain a period’s open time, we can use either CopyTime() https://www.mql5.com/en/docs/series/copytime or SymbolInfoInteger() https://www.mql5.com/en/docs/marketinformation/symbolinfointeger I’ve attached a script testing the speed of each showing that SymbolInfoInteger() is faster than CopyTime() by 50%, even after optimisation. Just throwing it out there.
‘Selecting’ a Position “copies data about a position into the program environment, and further calls of PositionGetDouble(), PositionGetInteger() and PositionGetString() return the earlier copied data. This means that the position itself may no longer exist (or its volume, direction, etc. has changed), but data of this position still can be obtained. To ensure receipt of … Continue reading
Posting this as a repository for myself as I can’t remember what I wrote yesterday much less a few months ago. This script illustrates 2 things: 1. Getting indicator values in MQL5 is more laborious than in MQL4 if you only need 1 value 2. Calling a default indicator function versus iCustom() Know that iMACD() … Continue reading
Getting a price at a Fibonnaci percentage level is a straightforward mathematical calculation. We just need to define 3 things: 1. Price at 100% 2. Price at 0% 3. Percentage to return Price at This is a script illustrating all the calculation needed: You just need these 2 lines to to obtain your required price … Continue reading
A quick script illustrating making your extern inputs as a dropdown list of fixed options. This is what will be seen.
Simple script illustrating getting the maximum value in an array. Code identical for MQL4 and MQL5. MT4 output: MT5 output:
There’s a few things that could give the Invalid Prices error from OrderModify. 1. If you are trying to modify price, SL, TP, with the same values as before. 2. If you are trading on an asset which tick size is not the same as the smallest increment of the least significant value, e.g. Nikkei 225 mini … Continue reading
A quick script illustrating how to get the P&L of the last closed trade with MQL5.
Yesterday night at 11:45pm I was coding for the past hour-plus and my wife was chasing me to shower and sleep, telling me I would have 20 mins to finish up. 10 minutes in and 2 decision trees in my neural RAM, she comes and tells me the spare toilet’s cistern is dripping water. I … Continue reading
24th June 2016 saw one of the highest days of volatility coupled with illiquidity ever seen. I happened to be logging tick data when it occurred. This post shows the spread across 3 brokers servicing different clientele and with different liquidity providers. To put things into perspective, the typical spread for GBPUSD is around 1 … Continue reading
Taking a leaf out of Mario Draghi’s book when the ECB reduced their Deposit Facility Rate to negative 0.10% on 5th June 2014, the Swiss National Bank has just done the same on sight deposit account balances, with a rather aggressive negative 0.25%. ” Negative interest is charged on sight deposit account balances (cf. art. 2.1.1, Terms of Business) … Continue reading
This error, 4106 ERR_UNKNOWN_SYMBOL, occurred when the chart, where an EA compiled on MetaEditor 4.00 Build 409 (25 Oct 2011) running on the latest MetaTrader 4.00 Build 610 (14 Feb 2014), had its timeframe manually changed from one to another, e.g. H1 to H4. Reverting back to the launch timeframe did not resolve the issue. … Continue reading
It’s gratifying to see Metaquotes continue developing for MT4. I never migrated to MT5 due to my severe reservations about MT5’s position-centric (likely due to NFA’s nonsensical FIFO rule) vs MT4’s order-centric system. And while I’ve yet to find a tangible benefit of OOP over procedural coding, this unified MetaEditor will (or at least should) allow … Continue reading
I see this tripping up MT4 programmers enough that it warrants a post. A quick background for the uninitiated, Metaquotes structured MT4 EAs with 3 main event processes. init(), start() and deinit() This is clean, minimal and logically sound. init() runs ONCE on starting up, or when editing your EA properties, allowing you to do … Continue reading
Metaquotes promptly resolved the compiler error with build 509. Good going! http://forum.mql4.com/56329
New build. Features and updates as announced here. http://forum.mql4.com/56286 With the release of build 500 and its forcing of update for existing builds above 482, there’s been quite a bit of ire from developers. Justly so because newer builds tend to break some functionality, see https://raidenworks.com/2012/08/11/metaeditor-corrupt-compile/ and build 417 errorneous return of double from the DLL functions. And it’s … Continue reading
Quick post, Metaquotes has rolled out their latest MT4 build 500. Significant thing to note is that it appears to be a mandatory update the moment your selected broker decides to roll it out to clients, i.e. completely bypassing the liveupdate.exe in the root folder. The most glaring intro to this is a pop-up window you’ll … Continue reading
Some background on short circuit evaluation (skip this if you already know what it is): Examine this if statement with a logical OR operator: If there is short circuit evaluation(“SCE”), as long as the leftmost condition fulfills, the entire if OR statement fulfills and passes control to the next line. If there is no SCE, … Continue reading
MT4 build 482, a jump from 451, has been released on 2013-03-09. http://forum.mql4.com/54431 A key feature is item 2: Terminal: Increased the number of allowed parallel trading operations for MQL4 programs – up to 8 parallel trade requests are allowed now. This ensures uninterrupted simultaneous trading of several scripts or Expert Advisors – it means … Continue reading
Keeping things trading related, many a times you will come across in a forum, or a publication, or been advocated to by another person, a technical system where a whole bunch of charts are shown how a setup is ideal for predicting the following profitable price movement. A highly compelling story of its success is painted by … Continue reading
Here’s some simple plots of the EURGBP spread during the course of a day. Initially tried to use Excel but R handles it much faster and leaner. You can evidently see the spikes during news releases and a general increase as the liquidity drops during the Asian hours. 2012-10-07, 2012-10-14, 2012-10-21 are Sundays. Green line … Continue reading
I spent the better part of yesterday figuring out where I might have accidentally written an infinite loop. Reason being that the moment I started my backtest, MT4 would crash upon accessing the EA. It seemed the most plausible explanation and I went about combing through every new line. What I couldn’t rationalise was that … Continue reading
With the latest debacle of Peregrine Financial Group Inc. CEO, Russell R. Wasendorf, Sr., misappropriating client funds, of which at least $200 million is currently unaccounted for, one has to really ask just how do you measure specific counterparty risk? Note that Peregrine Financial Group Inc., better known as its online moniker, PFGBEST, was a … Continue reading
This is a very simple trade management EA that will close all your Open Orders (or both Open and Pending Orders) when your drawdown against balance exceeds a set percentage limit. E.g. Balance = $10,000 and “DrawdownPercent” is set at 2.0, if floating P&L is greater than -$200.00, all Orders will be closed. A simple … Continue reading
Occasionally, your connection to your broker’s price feed is disconnected, either because of your own terminal/router/modem issues, or issues arising from your internet provider/VPS service. This happens often enough that most programmers will consider how their EA’s will pick up and manage open positions when the connection returns. However, as with what I experienced today, … Continue reading
A quick post 2012-02-07: I use the GetTimeZoneInformation function in the Kernel32.dll library to pull my system’s time, and hence calculate the broker time and consequently control my trading time window. Earlier today, I entered one of my VPS’s that I use for testing and discovered the GMT offset was off by an hour. I was … Continue reading
Connection speed is important when it comes to trade execution. To check your latency to your broker’s trade server, you need to determine the server’s IP, then ping it There is a good way to combine these actions by using a free program, WinMTR, by Vasile Laurentiu Stanimir (now hosted at http://winmtr.net/), which combines the tracert and … Continue reading
This post is split into 3 parts. Part 1 explains how MT4 records Relative Drawdown, which is not well understood. Part 2 will show my code to calculate Relative Drawdown against Balance just prior to a trade, which I inherently find much more useful. Part 3 shows the mql4 code for calculating and displaying this … Continue reading