Wednesday, August 13, 2014

Starting with MACD using shell scripts and C

I've been interested in FOREX trading since I enrolled in college around 8 years ago, reading pieces of articles about it here and there. I am now a 26 year old electronics engineer with some graduate school experience in computer science. I think I've matured enough, mathematically and intellectually, to start playing with the FOREX market.

I admit I have no formal or previous experience with trading. This blog is not intended as a guide of any kind. Much less as trading advice. This blog is about the development of my FOREX learning curve, from the very beginning. The notes contained here are for my personal use, but I will share them in case anybody out there wants to collaborate, make suggestions, corrections, criticism, or simply to learn alongside myself.

That said, I'll start by sharing some of the experiences I've collected so far.

I've started by becoming familiar with the basic FOREX trading concepts. I believe I have a good enough grasp on pips, leverage and the MACD to start playing around with an OANDA test account.

Recenly I've run some experiments using the OANDA HTTP API, UNIX shell scripts and C programming. So far I haven't been able to turn any profit using my MACD schemes with the OANDA API. I blame a set of factors for this:
  1. The input parameters I've used are based on only a few  trading simulations I ran using the EUR_USD price data of 3.5 days (5000 1-minute samples).
  2.  My simulations do not entierly represent real trading. I must improve them.
  3.  I am using MACD exclusively. I should try combining it with other methods, such as a 1-2-3 scheme and RSI.
I am aware that there exists software which already implements MACD and others. But I've refrained from using such things. Mostly because of my obsession with writing my own software, and with being in absolute control of what my software does. Still, I don't reject the idea of using pre-existing software. I think experimenting with pre-existing software may help me turning profit sooner. It may even help me improve my own software.

To solve the issues which have prevented me from turning a profit with my OANDA test account, I have formulated the following TODO list:
  1. Writing a proper trading simulator.
  2. Using such simulator to run a genetic algorithm which finds the optimal MACD parameters (genetic MACD tuning). These parameters include the typical 3 numeric values, and a fourth value representing the time frame for sampling closing bid price values.
  3. Run my MACD shell script with the obtained values.
  4. Copy this trading strategy: using only shell scripting and C programming, as to understand the nuts and bolts of MACD, 1-2-3 and RSI.
  5. Copy the same trading strategy using the suggested pre-existing software packages.
Currently my source code is not ready for publishing. I will polish it and then share it on my github account. I will be reporting as I finish the elements in my TODO list.


  1. Hello Everybody,

    Below is a list of the highest ranking forex brokers:
    1. Best Forex Broker
    2. eToro

    Here is a list of the best forex tools:
    1. ForexTrendy - Recommended Odds Software.
    2. EA Builder - Custom Indicators Autotrading.
    3. Fast FX Profit - Secret Forex Strategy.

    Hopefully these lists are benificial to you.

  2. Hey Everybody,

    "Which Forex pair and time frame is best to trade" is the frequently asked question and I want do give you the EXPLICIT ANSWER in this comment.

    Are you expecting that I am going to say something like EUR/USD on 10-minute time frame or GBP/USD on daily...? No, it is not so simple, but SIMPLE ENOUGH we can figure it out!

    The "PROBLEM" is that markets change over time. If GBP/USD was a well trending currency pair a few years ago, today it is another one.

    I actually want to let you know about a SPECIAL INSTRUMENT that I use to find the BEST TRENDING PAIRS among all the Forex pairs.

    GET THE SOFTWARE: ForexTrendy

    The instrument examines 34 Forex pairs on all time frames from minute to monthly. This way you choose the best trending pair and time frame at the current time.

    LINK FOR SOFTWARE: ForexTrendy