TradingView
RyanMartin
Aug 6, 2016 5:08 AM

MACDouble & StochRSI w/ safeties and variable time interval v0.3 

Description

UPDATE:
IMPORTANT!!! MAKE SURE "RECALCULATE AFTER ORDER FILLED" IS CHECKED.
I will have it on by default in the future.

This is a continuation of my previous scripts of two MACD indicators with a Stochastic RSI indicator.

New features:
- Alternate MACD time interval
You can now set the time interval for the second MACD indicator to a different resolution than the displayed chart.
Uncheck the box and select the desired interval. For example, if your chart is set to 15min then first MACD will be set at 15 min and you can select 5 min for the second MACD.

- Alternate StoRSI time interval
You can (and should) set the StochRSI to a different time interval as well. StochRSI hasn't worked great with previous versions. Now you can set it to a different time resolution as well. I strongly recommend you set it at a higher (slower) resolution; for example if your chart is set at 15min then you should test setting the StochRSI at 30 or 45min.

- 'True" StochRSI logic
Trading logic for StochRSI is now a true StochRSI, instead of just reading "k" and ignoring "d", K now has to be greater than D to buy and less than to sell.

- Safeties
A primitive but low risk safety in the form of an uptrend/downtrend price safety. If current close+high isn't greater than the previous close and high then the buy order will not be executed. The same applies for sell orders.

- Cap on losses from short positions
A stop loss safety set to 9000 for exiting sell positions. This will need refinement in the future but this puts a cap on losses from any sell position. At an initial currency of 10,000 this translates to 90.00. If it is giving you problems simply delete line 78 from the source code.


Please feel free to ask any questions or send me suggestions. This is still very much a work in progress and I'll try to polish up the rough spots but it is fully functional. With a slower StochRSI and the safeties I have gotten it to consistently outperform the old 2x MACD strategy script---typically by 3-fold.
Comments
harshv61
"RECALCULATE AFTER ORDER FILLED" IS CHECKED"

Try to trade it live. You won't get a chance to enter end exit on the same candlestick. In the end, this strategy will backfire...
lqtacy
i need alertcondition for this indicator. i wrote but it didn't work
RyanMartin
@lqtacy, Can strategy scripts have alerts even? I think that may be the issue because I loaded this and a couple variations I have of it which are all strategy based scripts and any time I went to create an alert it wasn't an option to select on the dropdown TV has for alerts.
I think I have similar indicator based scripts that you can try and those do work with alerts. If that's no good and you aren't using this as a strategy/backtesting script anyway (that is, you are using it as an indicator script primarily) then I'm sure this can be retooled.
burakmertcan
Does it repaint?
RyanMartin
@burakmertcan, it's a bit outdated. I have variations that have some style, simple indicators. Can you clarify what you mean by repaint? Like actually draw the MACD lines and such? when I made this TV was alot--- less shitty and would let you have more than three indicators loaded on a chart, it was like 7 or 10. If this is what your looking for let me know and I'll update.
burakmertcan
@RyanMartin, I have some ideas. I want to report it to you. My English is bad, sorry.
More