TradingView
TrendsAreSexy
٩ تشرين الأول أكتوبر ٢٠١٩ ١٣:٥٧

Easy to Use MACD+RSI Strategy 

BROOKFIELD INFRASTRUCTURE PARTN L.PTSX

الوصف



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!

التعليقات
swmacint
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.
TRACANTE
@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.
UnknownUnicorn16043985
@swmacint, good idea. Thanks!
jimschougaard
@swmacint, @swmacint, Hi mate, I am new beginner, and are try to using his script. I have put in these lines. Can you show me your script? I will be very grateful.
Best regards. Jim.
///// Submit orders /////
if (afterStartDate and crossover(macdLine, signalLine) and macdLine<0) and rsivalue<35
strategy.entry(id="BUY", long=true)
if (afterStartDate and crossunder(macdLine, signalLine) and macdLine>0) and rsivalue<60
strategy.entry(id="SELL", long=false)
MadMoto29
Hi! How could we adjust the RSI levels (eg instead of 30/70, make it 20/80)? Thanks =)
TrendsAreSexy
@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.
mac_dick
Is this a script to set an alert or something else?
TrendsAreSexy
@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.
consciousSeafo89706
Hi, I was wondering if someone has updated this script to version 4?
Joeanucha
No, this is not working properly. You miss most of good trades with this. You should remove the RSI or have an option for it. But thanks for the work tho. But i manually bactest and also did real trades in 2020, your indicator shows a complelely opposite result.
المزيد