Paper Trading on ECN - Noob Idea: Biding the Reversals onto a Stable Oscillating Rate

I’m afraid that my chart making skills will need some polishing up. Here is an effort at illustrating a thesis with a graphic. I’ve created the following chart with MetaTrader 4 * in a 5M perspective about of the USDCADi** market

Looking at the chart, it may seem that - in this morning’s trading on USDCADi, up to the duration illustrated - that there’s a certain periodic kind of waveform of the market rate, over time - like a continuous sine wave, or a continuous cosine wave, but as plotted across each individual “Tick” of the discrete OHLC*** data in the chart.

In regards to the market rate, I understand that the “Sine Wave” as such represents a series of market-rate reversals. I believe that when the market is stabilizing within such a periodic erm, waveform, that it may be possible to incorporate such observation into a manner of a narrow-frame technical analysis.

My chart is not a perfect illustration of the thesis. In this paper trading, ut seems that I had - at one point - dragged the bid’s actual … but paper-traded … stop-loss marker, thus modifying the paper bid – when what I had meant to drag with the mouse cursor was, instead, a nearby line on the chart. So, I would caution anyone about working with chart lines at points near any bid limits in any open positions - that with the “Click to select” option**** enabled for the charts, in the MetaTrader options settings, one might accidentally drag a part of a bid along the chart when the chart lines and the bid lines are very close together.

I had not known that such an “OOPS” was possible, until this day’s session in paper trading. Surely, in any live trading, I should wait until all bids are closed before modifying any charts on the graph. I’m trading with a demo ECN account on TradersWay.

The idea, which I had hoped to illustrate despite that S/L Drag-and-Drop “OOPS”, I might try to summarize it as follows:
[li]That if the market is oscillating regularly …
[/li][li]… and one may estimate a median value between the market-rate high/low peaks in the oscillation …
[/li][li]… then one may endeavor to bid Sell and set the stop-loss and take-profit limits such that for the stop loss, may allow for any reversal at the top of the chart - in a Sell bid - thus that the stop-loss for the sell bid could be maybe a little higher than the periodic crest of the market rate, and such that for the take-profit limit, it would be also a little higher than the low-rate peak, such that might ideally serve ensure that the Sell bid exits at-or-near the low rate before the market rate reverses
[/li][li] Contrarily. for a Buy bid, one could set the stop-loss at lower than the low-rate peak of the oscillation, and one could set the take-profit rate at a little bit lower than the high-rate peak of the oscillation. Thus, ideally it could allow for a reversal at the low end, and could serve to ensure that the Buy bid exits at the high end.

Essentially, this would describe a positive offset for sell bids, and a negative offset for buy bids, as in relation to the demonstrated periodic ‘high’ and ‘low’ limits of the oscillating market rate.

I believe it’s fairly simple in an intuitive sense. I’m fairly certain that it could be easy to code into an expert advisor. Personally, I’m simply glad I’ve figured out any way – or anything towards any way – to make well of the constant market reversals.

Of course, the entry rate for each bid could be set at the median rate between the high and low limits of the demonstrated waveform.

I’m sure there’s a lot to learn in regards to technical analysis of broad trends. Presently, I’m trying to understand the realtime data I’m seeing in my demo ECN account. I hope that my explanation might not be too opaque, as to this proposed thesis.

  • All copyrights apply

** It seems that the ‘i’ suffix in the symbol, USDCADi, may indicate that it is an ‘intrabank’ symbol i.e that it is a symbol being traded on the ECN network

*** as in regards to a type of datum representing a set of market rates at Open, High, Low, Close points in a single time frame - essentially a kind of data tuple, as may be ploatted onto a Candlestick Chart or a Bar Chart

**** In the MetaTrader 4 GUI, there in the ‘Options’ dialogue window, then on the ‘Objects’ tab, there’s check-box labeled ‘Select object by single mouse click’.


I recognize the pattern. One question with regards to a script. The market is oscillating all the time. How will you explain the script when to apply your strategy? How should the script isolate the oscillation that you are looking for. Have you thought about that?

Just a challenge to fuel your thinking process.

Thanks! I’m thinking there may be a math to it somehow, at least for making a mathematical analysis of a stable oscillation in the market rate.

Hypothetically, if there may be a mathematical method for interpolating a sine wave over the market data as so - broadly, if there’s a mathematical method for interpolating a continuous waveform onto a set of discrete data points - perhaps the ‘max’, ‘min’, and ‘median’ values for the system could be calculated initially from the interpolated, continuous waveform.

Of course, I’m not immediately familiar with statistical mathematics enough to know of any exacting kind of numeric methodology as so. I started trying to look it up, last night - found a lot about differential genetic statistics, not so much about finance. In regards to biomedical applications of statistics, I believe the calculations are constrained onto the set of {A,D,C,G,T} (?) base pairs - that it may not be quite the same as with the OHLC data forms, i.e sets of tuples of numeric market rate data under specific 1M, 5M, 60M … data sampling rates.

If there may be any really complex mathematical methods available for detecting a periodic waveform as so, I wouldn’t want to bedazzle with a note about Fourier Series. I’m hoing there may be something approximate to such a method, for mathematically detecting any stable oscillating period in the market data - if not for also detecting if the period numerically “walks” to a lesser max/min/median or greater max/min/median – if not a wider or narrower max/min distribution – across any later market trends.

Presently, candidly, I’m only applying my own organic analysis faculties – with some limited knowledge of mathematics – mostly focusing on the trends of the real-time ECN data as illustrated in the MetaTrader “One-click ordering” widget and the “New Order” widget, all in paper trading. If there may seem to be an intuitive method, perhaps it might seem somehow less mystifying than all of the details of any formal mathematical method, I wonder?

Maybe, there is an easier way. Try the same MA as you use in your chart and copy it but with a shift of 10. That way the MA is more ‘in sync’ with the wave the bars are following and creates a two-dimensional helix with cross points.

That shifted MA would probably follow the median price of the bars, indicating that there is a stable oscillation. Perhaps it will move between the MA based on the highs and the lows.

Also, such patterns normally have a small bandwidth. Most likely a high MA (eg 200) may be encapsuled by the helix.

Thank you! I understand that the term MA denotes a concept of a moving average. Not to seem too ostentatious, but if there may be other math geeks in the forum, I’ve found a very short video lecture that serves to describe a concept of calculating an MA. The video applies the concepts as in a manner canonical to a quarterly demand analysis [I]viz a viz[/I] commercial retail sales services

I’ve found a number of books at [plug] Safari Books Online denoting the concept – many of which books may seem describe, prototypically: How to calculate MA for calculations performed on any one of some various software platforms, e.g Clojure, Excel and Visual Basic etc. Towards a platform-agnostic mathematical perspective, I’ve found an introduction to Sequences and Series, as namely in a context of manners of Calculus, such that I believe may serve to make a helpful introduction before a fairly more applications-oriented example focusing on trading, as [I]viz a viz[/I] “Some exact results for moving-average trading rules with applications to UK indices” from the book, [I]Advanced Trading Rules[/I] (2nd edn).

Not to Pimp the Safari Library LoL, personally I’ve been impressed by the breadth of coverage in the books available via the Safari subscription service. I understand that the service is run by O’Reilly Media, and that they’ve networked with Pearson, on the publisher side.

Though I’ve noticed that MQL is fairly a C-like programming language, personally I’m much more a fan of the Lisp programming languages - such as Common Lisp if not the couple of standard Lisp dialects typically denoted as [I]Scheme[/I]. Personally I’m afraid that my own logical faculties are a bit distracted with following a [I]commodity dollars[/I] market, this morning. I think that the [I]moving average[/I] concept makes a great keynote towards some of a semantically correlated mathematics, however. I appreciate the advice - will direct the rest of my notes into my Evernotenoteooks LoL.

Yes, MA is a moving average. It is a standard function in MT4, so that is why I suggested it.

I’d like to keep a script as simple as possible and forex is following mathmatical rules not yet discovered, so the MA is the easiest to be used to see oscillation. It provides some visual navigation that youcan easily incorporate in an Expert Advisor.

But if you are a math geek I can imagine that you like to work out the math and tweak it to match your observation… :smiley: Just offering some easy tools to help you on your way. :wink:

Feel free to keep asking questions. I enjoy seeing how you dig yourself a way into the concepts… :slight_smile:

With regards to MT4 programming, yes it is comparable to C++. It works for me, so I am a happy trader… :slight_smile:

After reading some of the MQL4 documentation this evening, I think that the albeit simple mathematical functions of numeric ‘maximum’ and numeric ‘minimum’ could serve to be of some use in a mechanical trading system.

Hypothetically, an algorithm could compute the “Lowest” minimum and “Highest” maximum of a series of discrete data values - such as with an average rate computed of the open and close or high and low rates in a set of OHLC bars - then recording the index of the data-tick bar or tuple containing the respective min/max data values. Proceeding from there, the algorithm could repeat the computation onto a subset of the data values delimited by the respective ‘min’ and ‘max’ bars, thus iterating until reaching a certain step limit at which no more ‘min’ and ‘max’ bars would be computed.

Then, as across every interval in each ‘min’ and ‘max’ set, the “rate slope” could be computed. Any number of indicators, ostensibly, could then be derived from the resulting data. For instance, any reversals in the market rate could then be detected, as to when the “rate slope” would shift from a “Positive” to a “Negative” slope, or vice-versa. Also, the “steepness” or numeric mangnitude of the slope would serve to indicate how quickly the market rate shifted across each respective duration. The duration itself - as between a market rate ‘min’ value n and the ‘next min’ at n+1 or contrarily, between market rate ‘max’ values in the chart - the duration itself would serve to indicate how long of a time elapsed before the next market rate reversal.

With some manner of an offset padding in the hypothetical Expert Adviser, hypothetically the slope detection procedure could recommend a trade at a time early when a reversal has ensued, in the market rate - but to estimate whether a reversal may last for any “Useful” duration, I believe it will require some additional data, if not to simply rely on the intuition of the trader at the terminal. Furthermore, there could be a function defined as to to calculate the market spread between the ‘ask’ and ‘offer’ rates in the respective currency pair, like as to ensure that any open positions may be profitable, ideally - or at least, not occurring to loss - at even a “Low water mark”.

Also, there’s the question of how it would interact with the user? Candidly, I’ve not found any window-building functions in the MQL documentation, outside of the chart/indicators functions. Any manner of an external GUI service implementation, as well as it needing any manner of a new UI/UX design, it would serve to require some sockets networking and a data model.

Perhaps some sort of a nuanced algorithm could be developed for calculating the take-profit and optional stop-loss settings on any open positions, furthermore.

Lastly, though completely orthogonal to the mechanical trading itself, of course there is all of the ongoing “market news” - no doubt serving a role in regards to market assessment, by the trader ultimately at the terminal?

The UI present is very rudimentary. The EA can inform the trader through textboxes, alerts and prints. A way to interact is through GlobalVariables. But MT4 can ex-/import to csv-files that can be used for an external GUI. I am thinking about making one but I am too busy atm.

Moving Averages already limit the effects of min and max bars in a range. It is also possible to have the MA based on the median price of a bar. This may serve as alternatives, but excluding maximums is not difficult. What about basing the bars by only the open/closes, excluding any ‘wigs’.