TrendsAreSexy

Easy to Use MACD+RSI Strategy


BEGINNERS REJOICE!

Easy to use strategy test using MACD with RSI as a confirming indicator. The code is structured to make it easy to manipulate the variables to your choosing.

EASY TO CHANGE CODE VARIABLES
LINE 2 = Change the amount you invest every trade and the currency
LINE 8/9/10 = Change the defval of each of these lines to backtest from a certain date
LINE 16/17/18 = Change the MACD sensitivity by changing the defval on each line
LINE 21 = Change the value after close toadjust the sensitivity of the RSI
LINE 37/39 = Change/remove the < and > variables for macdLine and rsivalue after the crossover/crossunder to adjust your buying point further.

As a beginner you may not feel comfortable with shorting stocks, therefore LINE 5 was added to only allows long positions.

Funny how a simple indicator can return such a high profitability. Couple this with some trend/exit strategies and you'll have something really special!

Remove from Favorite Scripts Add to Favorite Scripts

Comments

Is this a script to set an alert or something else?
+2 Reply
@mac_dick, it's most useful as a back-testing strategy, a way to see how profitable a security is based on the MACD/RSI variables you put in place. It does show you when to buy/sell, but it won't actually send you an alert.
Reply
Hi! How could we adjust the RSI levels (eg instead of 30/70, make it 20/80)? Thanks =)
+1 Reply
TrendsAreSexy MadMoto29
@MadMoto29, Within LINE 37 and 39 you can adjust your buying parameters by changing the value after rsivalue. You'll see in the code above that the buy order uses an RSI value of less than 50. You can adjust this and add this portion to your sell order code to tweak your numbers further.
+1 Reply
Hi thanks for sharing this. Would you be willing to fork a version suitable for binary options testing, or share a line or two of code for what to add? I'm sure the only thing missing is the ability to set the expiry time (eg in candles). Thanks for considering!
Reply
Thanks for posting this! For anyone playing around, I was having significantly less luck than the above performance, so adjusted to also sell if rsivalue > 70. Profits jumped significantly in backdating testing. Just food for though.
Reply
kjbint swmacint
@swmacint, Hey, mind sharing your updated script with me? I have been trying to rewrite the above using pine version 4 vs the 2 it was written in but havent had much luck.
Reply
what is the purpose of the Hline code on line 30?
Reply
TrendsAreSexy Hodl4dearlife
@Hodl4dearlife, it plots the dashed horizontal line you see in the MACD section. Entirely cosmetic.
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out