Hello my fellow traders and coders! I have an algo to present that i have been working on. 

I used OANDA currency correlation website to find the pairs with as close to 0.9 negative correlation in the past year. As the title suggests i'm going long and short on 2 negatively correlated forex pairs to maintain a price neutral position, when the pairs go above or below their average spread between their 2 prices. For the USDCAD and CADSGD: when the current spread is below the 10 period spread SMA it buys the USD and shorts the CADSGD(aka buying the SGD). So effectively i'm long USDSGD. When the current spread between USDCAD and CADSGD price is higher than the SMA i buy the CAD both ways by shorting the USDCAD and buying the CADSGD.  This is the same for my 2nd grouping EURNZD and NZDUSD. The only difference is that i noticed for this grouping, the algo performed better when i liquidated the price neutral positions as the current spread returned to the 10period SMA of the spread.  In the code you will see i'm working on a GBP negative correlation trade but i couldn't get the numbers right so i just commented everything out. 4 pairs should be enough atm. 

Goal: to achieve above 65% win rate and a 1.25 or great profit/loss ratio. I wanted to trade 4 pairs minimum and 6 maximum. 

Pros: With price neutrality, daily resolution, high win rate, and moderate profit/loss ratio, we are able to trade a higher quantity of currency lots because we are affectively hedging our positions agaisnt another currency that is strongly correlated. 

Cons: checking in every month to make sure that pairs are still correlated. We may have to tweak the tolerance variable (line52-54) depending on the correlation coefficient on the oanda site. https://www.oanda.com/forex-trading/analysis/currency-correlation

Disclaimer: I"m a traditional trader learning to code. So please talk to me like a 5 year old when offering feedback on my code. I am live trading this as of yesterday.

 

 

Author