MACD Crossover trend strategy, Long and Short

conflixx95493 업데이트됨   
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.
릴리즈 노트:
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.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.


이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?