Codes

Rapid Doji EA for MetaTrader 5

The Rapid Doji EA is a fully functional MetaTrader 5 Expert Advisor that uses pending orders (one BUY and one STOP) around each Doji candlestick on the Daily (PERIOD_D1) time frame. This is a great introduction to how to build a simple, profitable EA. You can watch, step-by-step, how this EA was

Optimal F for MQL5 (per Ralph Vince) for MetaTrader 5

This calculates Optimal f using the Geometric Mean. Per Ralph Vince, "In trading we can count on our wins being for varying amounts and our losses being for varying amounts. Therefore the Kelly formulas could not give us the correct optimal f." So, using his equation(s), I created this library for

Forum

CodeBase Validation tester says [Invalid volume].

The volume is a fixed value of 0.10. Searching the forum suggests that [Invalid volume] is usually because of an issue with SYMBOL_VOLUME_MIN or SYMBOL_VOLUME_MAX or SYMBOL_VOLUME_STEP , but 0.10 is fixed, and I think a fairly standard size for EURUSD. I had a few invalid price issues, but nothing

Jamming a very large long into a double

ChartID() returns a long. In general, it seems to be a rather large number. When I put it into a double, e.g. into a Global Variable of the Client Terminal, it gets changed due to loss of precision. So . . . I was thinking . . . I don't really need to know the exact ChartID() number. I just want to

Determine if three doubles have the same sign

Here's what I have so far, and it works, at least it seems to. Is there a better way to do this? Also not 100% sure of the 0 condition. I'm interested in any commentary that generates an interesting, more efficient, and/or more elegant function in MQL5. // Check if three doubles have the same sign

Lot value calculation off by a factor of 100

Scenario: 2 separate brokers who both have a NASDAQ100 index. When I calculate Lot value in USD (base currency), Broker 2 is 100X greater than Broker 1. The Calculation: double GetLotValue( string symbol, const double lotSize, double & pointValue, double & pipValue) { double contract =

MQL5 - "pointer to this function type is not supported yet"

I'm guessing the error message means exactly what it says. Can anyone suggest a clean work-around? #property strict typedef bool (*SignalFn)( void ); // Global function definitions bool IsBuySignal() { return true ; } bool IsSellSignal() { return false ; } // Create an abstract base class class

MQL5 Templates - Saving a template w/ EA also saves <objects>

This is only a minor annoyance. Steps: Start with a "clean" chart. That is, just bars, no other indicators. Start EA with a dialog on it created from CAppDialog. This EA has labels, edits, buttons, etc. Save as Template. For some reason, the labels are stored in the .tpl file. For example: < object

MQL5 Indicators - indicator_type property must be specified

Just double checking. It appears that I can change any of the parameters dynamically, e.g. width, color, style, label, but I must have the indicator type as a compiler directive property, which does not ever change, e.g. #property indicator_type1 DRAW_LINE Is this correct

MQL5: CopyTickVolume() returns same value for H1,H4,D1 for volume of current uncompleted bar

Here's a test script that depicts this odd behavior. The documentation says: If you need to return value corresponding to the current uncompleted bar, you can use the first form of call specifying start_pos =0 and count =1. Note: when I pull the volume for the first completed bar, i.e. START_POS =

MQL5 - CArray sorts only once

This isn't really a question per se. It's more of a comment on something that tripped me up for a bit. I found a work around, but maybe you can comment on a better work around. So, CArray has a Sort() method that looks like this: void CArray::Sort( const int mode) { //--- check if

MT5 - ChartApplyTemplate() applies template, but EA's auto-trading is disabled

From a pushbutton on a chart, I open a new chart: long newChart = ChartOpen (pair, PERIOD_D1 ); then apply a template (which is defined with an EA on it): if ( ! ChartApplyTemplate (newChart,InpTemplateName) ) { PrintFormat ("Failed to apply template [%s] to chart [%d]"