Back

macd indicator

Hello,

I am kind of new here and I need kind of an advice from you. For me this is kind of a more complex problem.
I would like to make an algorithm based on macd indicator and signal line. Lets say I will trade EURUSD.
The strategy would be that if the macd crosses signal line from beneath I predict that EUR would get stronger against USD and so I buy EUR and the when I make lets say 0.5% I will sell it. On the other hand when macd crosses signal line from above I predict that USD is going to be stronger against EUR and so I will buy USD as it is going to get stronger and then again sell it with some profit.
Of course this is only the idea, but I somehow can not imply the buying thing for both. Because for stocks it is just buying and selling but in forex, you can buy either USD or EUR and then sell them.

Sorry if the explanation is not straight forward, I apologise and I would be really glad if you would give me some idea or post a bit of code that would solve this problem.

Thank you

jjk
Update Backtest








Hello @jjk, welcome into the world of Algorithmic trading :)

Buying and selling forex is quite a bit different than buying and selling stocks indeed, however it doesn't work the way you described. Forex is traded in pairs. That is, if you BUY the EUR/USD currency pair, you are not only buying Euro’s; but you are also selling dollars. This indicates immediately how your strategy would work in practice.


  • MACD crosses from beneath [tex]\rightarrow[/tex] BULLISH signal [tex]\rightarrow[/tex] BUY EUR/USD
    • You have now bought [tex]x[/tex] EUR/USD units. Meaning you have bought [tex]x[/tex] euro's and sold [tex]x[/tex] dollars

    • [tex]\rightarrow[/tex] SELL when 0.5% profit: sell the [tex]x[/tex] euro's and buy back the [tex]x[/tex] dollars


  • MACD crosses from beneath [tex]\rightarrow[/tex] BEARISH signal [tex]\rightarrow[/tex] SELL EUR/USD
    • You have now sold [tex]x[/tex] EUR/USD units. Meaning you have sold [tex]x[/tex] euro's and bought [tex]x[/tex] dollars.

    • [tex]\rightarrow[/tex] BUY when 0.5% profit: buy back the [tex]x[/tex] euro's and sell the [tex]x[/tex] dollars.



The idea of trading forex pairs is therefore equivalent to simultaneously trading both underlying currencies. Otherwise, how would you define "buying [tex]x[/tex] dollars". This because if you are buying [tex]x[/tex] dollars, then what are you buying them for? For which currency?

So there's always a simultaneous trade between currencies when you trade forex.

However, good news: this doesn't change anything for your strategy. As described above, you would still employ your strategy in the exact same manner. However, you just BUY and SELL the currency pair opposed to, what you believed, buying and selling the currencies themselves (but for what?).

I hope this helps to get rid of your flaw in reasoning. For reference, read >this< and >this< .
1

Thank you for the welcoming party and your ideas :)

Well you helped me a bit, but for instance I traded on saxotraderGO. It looks like this: http://www.financemagnates.com/forex/products/platform-review-saxotradergo-one-screen-to-rule-them-all/

And if I have my money in dollars and I am trading GBP/EUR pair when I by GBP it does not mean I sell EUR, because I do not have any I have dollars, which are converted to GBP I buy. And then I just sell this position when GBP become stronger against EUR and I get it back on dollars again.

May be you are describing the same thing, just in a bit different way and I misunderstood it.
1

@jjk I think you still don't fully understand how it works. Maybe you can look up some articles about it? For example, Investopedia or sites like this one?
0

Welcome @jjk - I'd recommend making an attempt using the QCU How to use Indicators example algorithm. This lays out using MACD and a bunch of other strategies. If you get stuck please post your code here and others can help you with it.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed