JustUncleL

[Autoview][BackTest]Dual MA Ribbons R0.12 by JustUncleL

צפיות ‎3834‎
451
3834 11
This is an implementation of a strategy based on two MA Ribbons, a Fast Ribbon and a Slow Ribbon. This strategy can be used on Normal candlestick charts or Renko charts (if you are familiar with them).

The strategy revolves around a pair of scripts: One to generate alerts signals for Autoview and one for Backtesting, to tune your settings.

The risk management options are performed within the script to set SL(StopLoss), TP(TargetProfit), TSL (Trailing Stop Loss) and TTP (Trailing Target Profit). The only requirement for Autoview is to Buy and Sell as directed by this script, no complicated syntax is required.

The Dual Ribbons are designed to capture the inferred behavior of traders and investors by using two groups of averages:
> Traders MA Ribbon: Lower MA and Upper MA (Aqua=Uptrend, Blue=downtrend, Gray=Neutral), with center line Avg MA (Orange dotted line).
> Investors MAs Ribbon: Lower MA and Upper MA (Green=Uptrend, Red=downtrend, Gray=Neutral), with center line Avg MA (Fuchsia dotted line).
> Anchor time frame (0=current). This is the time frame that the MAs are calculated for. This way 60m MA Ribbons can be viewed on a 15 min chart to establish tighter Stop Loss conditions.

Trade Management options:
  • Option to specify Backtest start and end time.
  • Trailing Stop, with Activate Level (as % of price) and Trailing Stop (as % of price)
  • Target Profit Level, (as % of price)
  • Stop Loss Level, (as % of price)
  • BUY green triangles and SELL dark red triangles
  • Trade Order closed colour coded Label:
  • >> Dark Red = Stop Loss Hit
  • >> Green = Target Profit Hit
  • >> Purple = Trailing Stop Hit
  • >> Orange = Opposite (Sell) Order Close

Trade Management Indication:
  • Trailing Stop Activate Price = Blue dotted line
  • Trailing Stop Price = Fuschia solid stepping line
  • Target Profit Price = Lime '+' line
  • Stop Loss Price = Red '+' line

Dealing With Renko Charts:
  • If you choose to use Renko charts, make sure you have enabled the "IS This a RENKO Chart" option, (I have not so far found a way to Detect the type of chart that is running).
  • If you want non-repainting Renko charts you MUST use TRADITIONAL Renko Bricks. This type of brick is fixed and will not change size.
  • Also use Renko bricks with WICKS DISABLED. Wicks are not part of Renko, the whole idea of using Renko bricks is not to see the wick noise.
  • Set you chart Time Frame to the lowest possible one that will build enough bricks to give a reasonable history, start at 1min TimeFrame. Renko bricks are not dependent on time, they represent a movement in price. But the chart candlestick data is used to create the bricks, so lower TF gives more accurate Brick creation.
  • You want to size your bricks to 2/1000 of the pair price, so for ETHBTC the price is say 0.0805 then your Renko Brick size should be about 2*0.0805/1000 = 0.0002 (round up).
  • You may find there is some slippage in value, but this can be accounted for in the Backtest by setting your commission a bit higher, for Binance for example I use 0.2%

    Special thanks goes to @CryptoRox for providing the initial Risk management Framework in his "How to automate this strategy for free using a chrome extension" example.
Jun 09
הערות שחרור: Resolve some Issues
  • Resolve issue with Orange Close alerts not showing up in the TradingView alarm notifications when using Candlestick Charts.
  • Resolve issue with multiple Long/Short signals before Close by better use of the "tradeState" engine to keep control. This also made some of the Risk Management Code simpler.
Jun 17
הערות שחרור: Update Docs, Redesigned TSL for easier reading

Trade Management options:

  • Option to specify a Strategy start and end time script only.
  • Trailing Stop Level, TSL (as % of price), activated on open trade
  • Target Profit Level, TP (as % of price)
  • Trailing Profit Level, TTP (as % of price below/above TP), activated on price passing TP Level
  • Stop Loss Level, SL (as % of price)
  • LONG green triangles and SHORT dark red triangles
Trade Order closed colour coded Labels:
> Dark Red = Stop Loss Hit
> Green = Target Profit Hit
> Purple = Trailing Stop Hit
> Orange = Opposite (Sell) Order Close

Trade Management Indication:
  • TSL = Fuschia solid stepping line
  • TP = Lime '+' line
  • TTP = Black solid stepping Line.
  • SL = Red '+' line
Dealing With Renko Charts:
  • If you choose to use Renko charts, make sure you have enabled the "IS This a RENKO Chart" option, (I have not so far found a way to Detect the type of chart is running).
  • If you want non-repainting Renko charts you MUST use TRADITIONAL Renko Bricks. This type of brick is fixed and will not change size.
  • Also use Renko bricks with WICKS DISABLED. Wicks are not part of Renko, the whole idea of using Renko bricks is not to see the wick noise.
  • Set you chart Time Frame to the lowest possible one that will build enough bricks to give a reasonable history, start at 1min TimeFrame. Renko bricks are not dependent on time, they represent a movement in price. But the chart candlestick data is used to create the bricks, so lower TF gives more accurate Brick creation.
  • You want to size your bricks to divide the pair price by 500, so for ETHBTC the price is say 0.0805 then your Renko Brick size should be about 0.0805/500 = 0.0002 (round up).
  • You may find there is some slippage in value, but this can be accounted for in the Backtest by setting your commission a bit higher, for example I use 0.2 or 0.3 for Binance.

NOTE: Most of my testing was conducted on Renko Charts, I do not have any optimized settings for normal Candlestick charts, I have left that for fellow Traders to discover.
הסר מסקריפטים מועדפים הוסף לסקריפטים מועדפים
JustUncleL
select "use opposite trade as a close signal" stoploss function does not seem to work. Is this the intended function?

I'm learning so many things from your code.
Thank you always



p.s I did not know if use " "message was hidden.
even know how to delete a comment. Sorry.
השב
@maooam, That should really be renamed to "Use Fast Exit to close Order". The intention was to close the trade when the median MA of the fast ribbon crosses the median MA of the slow ribbon, also this will also be set automatically to true if no SL condition is set as a fail safe.
השב
maooam JustUncleL
I think "Use Fast Exit to close Order" it is more advantageous to use it, but the problem is high loss rate.
If I apply this option with stoploss, it will pass the real stop-loss section.
What parts need to be fixed to stop the actual stop loss or change to the opposite position ?
I think not enough explanation., so I attach a picture.

Please understand my ignorance.

<img src="http://cfile215.uf.daum.net/attach/99DEA6465BC16E320E6D50">
<img src="http://cfile211.uf.daum.net/attach/990A32465BC16E3A0B0813">
השב
select the the stoploss function does not seem to work.
Is this the intended function?

I'm learning so many things from your code.
Thank you always
השב
Hello JustUncleL,
Thanks again for sharing your great script !

I'm having trouble with renko strategy: if we have a signal, but the next candle goes in the opposite direction, the entry of our trade is drawn in at the Open of the new candle instead of the Close of the previous candle, which is where we would enter the trade.
For exemple a short strategy simply based on direction change between two following Renko bars :
condition=open < close and open > close
strategy.entry(id = "Short", long = false, when = condition)
strategy.close(id = "Short", when = close>open)

Here's a snapshot for illustration :

On renko #1 we notice a open < close, and on renko #2 a open > close, so entry condition is triggered as soon as renko #2 is closed.
The issue remain here : opening position price is the open of renko #3 (ie 1.30812) instead of closing of renko #2 (ie 1.30680).
Hence strategy tester rely on false price entry.

Unfortunately TV support ain't really helping on this issue so far. How would you advise to manage this error ?

Thanks for your help
השב
@ZAnanas, Unfortunately, that is the nature of Renko bricks on Trading view and most other platforms. I don't see any way around it other than waiting for at least two bricks to say there is a change in direction.
השב
ZAnanas JustUncleL
@JustUncleL, I think problem remain the same, even waiting for a second brick : if this second is followed by new one in the opposite direction, the entry of the trade would still be wrong.
השב
@ZAnanas, I believe you are over thinking it. You need to look at it as a probability, rather than just looking at just a few bricks here and there. We cannot predict which way the next brick will go, only that in the past the price behaved in a certain manner.
השב
I forked this to make a blank template with some new features and easier switching between strategy and alerts here:
השב
Thank you very much for sharing. I like your other indicators and would like to test this one. But I am not getting any signals. I do not have pro edition so I cannot test it with Renko candles. But all the other candle types or settings dont show any signals. On the Alert one it does show but I would like to backtest to optimize settings.

Thanks again for sharing your work, im looking forwarde to playing with it :-)
השב
בית סורק מניות סורק מט"ח סורק מטבעות-קריפטו יומן כלכלי סדרות איך זה עובד‏ תכונות גרף מחירון חוקי הבית מנהלים כלים לאתרים וברוקרים יישומונים פתרונות גרפיים ספריית גרפים קלי משקל מרכז תמיכה הפנה חבר בקשת פונקציה בלוג וחדשות טוויטר‏
פרופיל הגדרות פרופיל חשבון וחיוב הפנה חבר לשוניות התמיכה שלי מרכז תמיכה רעיונות שפורסמו עוקבים עוקב אחרי... הודעות פרטיות צ'אט התנתק