TradingView
loxx
2022년 9월 16일 오전 2시 42분

Deviation Scaled Moving Average w/ DSL [Loxx] 

U.S. Dollar/Swiss FrancFXCM

설명

Deviation Scaled Moving Average w/ DSL [Loxx] as described in the “The Deviation-Scaled Moving Average.” article of July 2018 TASC . This is an adaptive moving average average that has the ability to rapidly adapt to volatility in price movement. This version adds Discontinued Signal Lines create the buy/sell signals.

What are DSL Discontinued Signal Line?

A lot of indicators are using signal lines in order to determine the trend (or some desired state of the indicator) easier. The idea of the signal line is easy : comparing the value to it's smoothed (slightly lagging) state, the idea of current momentum/state is made.

Discontinued signal line is inheriting that simple signal line idea and it is extending it : instead of having one signal line, more lines depending on the current value of the indicator.

"Signal" line is calculated the following way :

When a certain level is crossed into the desired direction, the EMA of that value is calculated for the desired signal line
When that level is crossed into the opposite direction, the previous "signal" line value is simply "inherited" and it becomes a kind of a level

This way it becomes a combination of signal lines and levels that are trying to combine both the good from both methods.

In simple terms, DSL uses the concept of a signal line and betters it by inheriting the previous signal line's value & makes it a level.

Included
  • 2 Signal types
  • Alerts
  • Loxx's Expanded Source Types
  • Bar coloring
코멘트
hdzavalanche
Hi Loxx, thanks for this and all the rest of your work. I'm mostly a ghost online, so I want to use this opportunity to say thank you for your amazing work and sharing it.

I've encountered a bug on multiple occasions when leveld happens to be barely above levelu, in conjuction with out just barely crossing under leveld, causing a sell signal to be hit. Then, often on the next bar, out crosses back over leveld, but since it never crossed over levelu, a buy signal was never hit for a very, very long time. (Or vice versa for all of this.)

This situation is fixed with math.{max,min}(levelu, leveld):
goLong_pre = sigtype == SM02 ? ta.crossover(out, sig) : ta.crossover(out, math.max(levelu, leveld))
goShort_pre = sigtype == SM02 ? ta.crossunder(out, sig) : ta.crossunder(out, math.min(levelu, leveld))

Similarly the coloring must be fixed with the same:
if (out < math.min(levelu, leveld))
state :=-1
if (out > math.max(levelu, leveld))
state := 1

This technically goes against the logic of what levelu and leveld represent by somewhat conflating the two in this way, but in practice, this usually only happens during very flat markets, so the effect is negligible at best, and it's probably best to just ignore this very low strength signal anyway. (The bug it fixes, on the other hand, has much greater effect in the right circumstances... one backtest lost out on a very long uptrend.)

I'll leave it to you to implement a slightly more precise fix if you feel it's worth it. :) (Probably not.)

Cheers!
Orph5781
@hdzavalanche, could you please post here the complete revised code so to add manually to our favourites? thanks
ricky06
Excellent, thank you.
gmeneguzzo
Thank you for sharing. What settings would you recommend me using 2D timeframe so that I can order my first Tesla ;) ?
더보기