Trend Following Algorithmic Trading Strategy Oanda API Python Code

27 March 2017, 07:02
Ahmad Hassam

Did you read the post on how to connect with Oanda API using Python?

I have written a new post in which I provide the python code for a Trend Following Algorithmic Trading Strategy.

This is a simple trend following strategy. First we connect with Oanda FXTrade platform using its API.

We sample the price after every 15 seconds. We can do it after every 1 second.

I have used 15 seconds to sample the price. After every 15 seconds we calculate the 5 period simple moving average and 20 period simple moving average.

In an uptrend we should have the 5 period SMA above the 20 period SMA.

In a downtrend we should have the 5 period SMA below the 20 period SMA.

Sounds simple? Yes this is a very simple algorithmic trading strategy just for practice purpose.

When 5 SMA is above 20 SMA we buy and when 5 SMA is below 20 SMA we sell.

You don't  need to practice this trend following strategy on a live account.

Opening a practice account with Oanda is very easy.

Test this trend following strategy on the practice account.

Share it with friends: