conflixx95493

MACD Crossover trend strategy, Long and Short

conflixx95493 Aktualisiert   
Hey everybody,

This is my first strategy and script I wrote mostly myself. There's tons of content out there to learn how to code in Pinescript and it's exactly what I wanted and needed in this time of my life.

In any case, I made a rather simple MACD crossover strategy that only takes trades in the direction of both EMA and SMA (there are inputs to change the length of the moving averages and lots of other stuff too).
If the MACD line crosses upwards on the signal line, while above the zero point of the histogram and the price is above EMA + SMA , it's a long signal.
If the MACD line cosses downards on the signal line, while below zero on the histogram and the price is below EMA + SMA , it's a short signal.

There are a lot of default variables that make no sense, for basically any symbol you're going to be looking at. You're going to have to adjust the EMA , SMA , backtest date, take profit, stop loss and all that good stuff yourself to find decently profitable parameters.

I made this myself because I couldn't really find a strategy out there that allowed for so much customizing and it's an easy way to get started in Pinescript.

If you have any suggestions, tips or you see a flatout mistake in my code, please let me know. I'm still learning, everyday and I'm enjoying every second of it.
Versionshinweise:
Initially I wanted to rewrite my MACD script and release a new one. Eventually it ended up looking too much alike and I've decided to just overwrite my previous MACD strategy.
My previous MACD script only had one option, it had a static stop loss and take profit. This is bad, I knew this from the beginning but I had to start somewhere. Now that I know how I can go around fixing that, I've decided to just overwrite my previous MACD script.

This script gives you two options, the entry signal is always the same, it's been the same in my previous script and it's the same now. The exit signals are vastly different though. Previously it was a static stop loss and take profit, now I changed it to either pullback decided by the 20 period high or low(basically Donchian Channels, which is why I say they're mixed). The other option is where we let the MACD indicator do all the work, if we're in a position(either long or short) when the MACD inversely corsses the signal line that means we exit our position.
Open-source Skript

Ganz im Spirit von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es besser verstehen und überprüfen können. Herzlichen Glückwunsch an den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Veröffentlichung unterliegt den Hausregeln. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie dieses Skript auf einem Chart verwenden?