Flying Dragon Trend For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I would like to know whether there is Flying Dragon Trend Indicator in Thinscript.
https://www.tradingview.com/script/L2wC1FSC-Flying-Dragon-Trend-Indicator/
find below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © MarkoP010 2023
#//Indicator plots user selectable Moving Average lines and a colored trend band between the MA lines. The trend bands can be turned off individually if required.
#//Trend pivot indicators are shown by selected risk level either when there is MA crossover with price (Leading MA Offset1 on Highest risk level, Lagging MA on Low risk level) or three bands with the same color at the same time (on Lowest risk level, Leading MA Offset1 crossover with Lagging MA). Pivot indicators can be turned off if required.
#//The Offset option shifts the selected MA with the set number of steps to the right. That is where the Magic happens and the Dragon roars!
#indicator("Flying Dragon Trend Indicator", shorttitle="Flying Dragon Trend Indicator", overlay=true)
# converted by Sam4Cok@Samer800    - 05/2023
#MA(source, length, type) =>
script MA {
    input source = close;
    input length = 20;
    input type = "EMA";
    def swma = source[3] * 1 / 6 + source[2] * 2 / 6 + source[1] * 2 / 6 + source[0] * 1 / 6;
    def VWMA = Average(source * volume, length) / Average(volume, length);
    def ma =
     if type == "EMA" then ExpAverage(source, length) else
     if type == "HMA" then HullMovingAvg(source, length) else
     if type == "RMA" then WildersAverage(source, length) else
     if type == "SMA" then Average(source, length) else
     if type == "SWMA" then swma else
     if type == "VWMA" then VWMA else
     if type == "WMA" then WMA(source, length) else Double.NaN;
    plot out = ma;
}
#//Indicator options
input riskLevel = {"Highest", "High", default "Medium", "Low", "Lowest"};# "Risk Level"
input indicatorsOn = yes;    # "Indicators"
#//Inputs
input ma1Type = {"EMA", default "HMA", "RMA", "SMA", "SWMA", "VWMA", "WMA"};    # "Leading Moving Average 1"
input ma1Source = close;
input ma1Length = 35;        # "Leading Moving Average 1"
input ma4Type = {"EMA", "HMA", "RMA", default "SMA", "SWMA", "VWMA", "WMA"};    # "Lagging Moving Average 4"
input ma4Source = close; # "Lagging Moving Average"
input ma4Length = 22;    # "Lagging Moving Average"
input ma1Offset = 0;     # "Offset1 Steps"
input ma2Offset = 4;     # "Offset2 Steps"
input ma3Offset = 6;     # "Offset3 Steps"
input ma4Offset = 2;     # "Offset Steps"
input useBand1 = yes;    # "Band 1"
input useBand2 = yes;    # "Band 2"
input useBand3 = yes;    # "Band 3"

def na = Double.NaN;
def last = isNaN(close);
def rHighest = riskLevel==riskLevel."Highest";
def rHigh    = riskLevel==riskLevel."High";
def rMedium  = riskLevel==riskLevel."Medium";
def rLow     = riskLevel==riskLevel."Low";
def rLowest  = riskLevel==riskLevel."Lowest";

def ma1 = MA(ma1Source, ma1Length, ma1Type)[ma1Offset];
def ma2 = ma1[ma2Offset];
def ma3 = ma1[ma3Offset];
def ma4 = MA(ma4Source, ma4Length, ma4Type)[ma4Offset];
def band1clr = ma1 > ma2;
def band2clr = ma1 > ma3;
def band3clr = ma1 > ma4;

#//Graphs
plot piirto1 = if last then na else ma1;    # "MA1"
plot piirto2 = if last or useBand1 then na else ma2;                 # "MA2"
plot piirto3 = if last or useBand2 then na else ma3;                 # "MA3"
plot piirto4 = if last or useBand3 then na else ma4;                 # "MA4"

piirto1.SetLineWeight(2);
piirto1.AssignValueColor(if band3clr then Color.GREEN else Color.RED);#Color.MAGENTA);
piirto2.SetDefaultColor(Color.DARK_GREEN);
piirto3.SetDefaultColor(Color.VIOLET);
piirto4.SetDefaultColor(Color.PLUM);

AddCloud(if !useBand1 or last then na else ma1, ma2, Color.DARK_GREEN, Color.DARK_RED, yes);
AddCloud(if !useBand2 or last then na else ma1, ma3, Color.DARK_GREEN, Color.DARK_RED, yes);
AddCloud(if !useBand3 or last then na else ma1, ma4, Color.DARK_GREEN, Color.DARK_RED, yes);

#//Indicator plot conditions
def longCondition = if rHighest then ma1Source > ma1 else
                    if rHigh    then ma1Source > ma2 else
                    if rMedium  then ma1Source > ma3 else
                    if rLow     then ma4Source > ma4 else
                    if rLowest  then ma1 > ma4 else na;

def shortCondition = if rHighest then ma1Source < ma1 else
                     if rHigh    then ma1Source < ma2 else
                     if rMedium  then ma1Source < ma3 else
                     if rLow     then ma4Source < ma4 else
                     if rLowest  then ma1 < ma4 else na;

def pivotUp = if longCondition and shortCondition[1] and indicatorsOn then low else na;
def pivotDown = if shortCondition and longCondition[1] and indicatorsOn then high else na;

plot pUp = pivotUp;    # "Up"
plot pDn = pivotDown;  # "Down"

pUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

pUp.SetDefaultColor(Color.CYAN);
pDn.SetDefaultColor(Color.MAGENTA);



#--- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
199 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top