blackFLAG FTS - SwingArm Trend Indicator using ATRTrailing Stop and Fibonacci Retracements

Status
Not open for further replies.
You don't need to change any of the script, just change the aggregation period to set the individual columns in the watchlist.

Do we need to change the ATRFactor or ATRPeriod to get the 10 Minutes, 1HR, 4Hr, Day column watchlist?
input ATRPeriod = 28;
input ATRFactor = 5;
 
@Ishaam I'm not sure what you mean by windows, but remember the watchlist is pegged to a certain, primary,Master scan of the criteria you set it as.
The custom quotes watchlist will then help you to determine secondarily, the swingarm condition in each column time frame.

How do I install the bullish and bearish alerts?
 
@Playstation Ok, I see I can create 2 x watchlists, so I'll just create the top watchlist for buys and the second one for sells.

mLOeLoc.png
 
Last edited:
Odd request would anyone happen to know how to translate this thinkscript into pinescript for tradingview curious as i enjoy they're mobile platform
 
@Craighaber71 could you please advice how you were able to set columns (30m/1h/2h/4h/d) with green and red background color & value. I applied your code:

Code:
input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
input fib1Level = 61.8;
input fib2Level = 78.6;
input fib3Level = 88.6;
Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
def trail = ATRTrailingStop(trailType, ATRPeriod, ATRFactor, firstTrade, averageType);
def stateLong = low > trail[1];
def stateShort = high < trail[1];
def BuySignal = Crosses(stateLong, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(stateShort, 0, CrossingDirection.ABOVE);
def ex = if BuySignal then high else if SellSignal then low else if stateLong then Max(ex[1], high) else if stateShort then Min(ex[1], low) else ex[1];
def TrailingStop = trail;
def Extremum = ex;
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def l100 = trail + 0;
def Fib1 = f1;
def Fib2 = f2; def Fib3 = f3;
plot data = f1 > f2;
AssignBackgroundColor(if f1 > f2 then Color.GREEN else Color.RED);

Now I am not sure if this a watchlist or a scan (that generally picks, sorts out tickers as they meet script requirements).
 
@mansor- watchlist, You may need to add code above using the gear in the watchlist created for the swing arm. Look for custom scripts and then copy/paste code. Replicate for the amount of columns desired. Make sure to identify the time in the script with the title.

@mansor-

Check this video, form Han -Tech LLC, it will show you how to customize columns around 6:40. I tried it and it works well.
 
@mansor- watchlist, You may need to add code above using the gear in the watchlist created for the swing arm. Look for custom scripts and then copy/paste code. Replicate for the amount of columns desired. Make sure to identify the time in the script with the title.

@ALV thank you for your help and thanks for sharing the video, it made it clear that watchlist is based of a scan & not different than a scan.
 
Works nice.. I've been looking at the swing arms on just the RTH sessions and still good zones and information. I use it in conjunction with 2 TMO True Momentum Oscillator with Higher Aggregation by- _Mobius.. Gives me better trade location for my style with /NQ... Many thanks to you and the community for putting these tools together..
 
I was able to add a single watchlist which includes both long and short swingarm color coding (green/red), as well as an indication if price has entered a certain fib zone (z2, z3, z4).

aob3bJg.png


Code:
# blackFLAG FTS SwingArms
# StudyName: blackFLAG_Futures_SwingArm_ATRTrail
# My preferred setting is 28 / 5 FOR ALL TIMEFRAMES
# Edited by: Jose Azcarate
# blackFLAG Futures Trading - FOR EDUCATIONAL PURPOSES ONLY
# TWITTER: @blackflagfuture

# ** Updated code below is to be used for custom watchlist column only ***

input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;

input fib1Level = 61.8;
input fib2Level = 78.6;
input fib3Level = 88.6;

Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);

def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
    then high - close[1]
    else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
    then close[1] - low
    else (close[1] - low) - 0.5 * (low[1] - high);

def trueRange;
switch (trailType) {
case modified:
    trueRange = Max(HiLo, Max(HRef, LRef));
case unmodified:
    trueRange = TrueRange(high, close, low);
}
def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);

def state = {default init, long, short};
def trail;
switch (state[1]) {
case init:
    if (!IsNaN(loss)) {
        switch (firstTrade) {
        case long:
            state = state.long;
            trail = close - loss;
        case short:
            state = state.short;
            trail = close + loss;
    }
    } else {
        state = state.init;
        trail = Double.NaN;
    }
case long:
    if (close > trail[1]) {
        state = state.long;
        trail = Max(trail[1], close - loss);
    } else {
        state = state.short;
        trail = close + loss;
    }
case short:
    if (close < trail[1]) {
        state = state.short;
        trail = Min(trail[1], close + loss);
    } else {
        state = state.long;
        trail = close - loss;
    }
}

def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);

def ex = if BuySignal then high else if SellSignal then low else if state == state.long then Max(ex[1], high) else if state == state.short then Min(ex[1], low) else ex[1];

def TrailingStop = trail;
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def l100 = trail + 0;
def Fib1 = f1;
def Fib2 = f2;
def Fib3 = f3;

def bullAboveZone = state == state.long and close > Fib1;
def bullZone2 = state == state.long and close <= Fib1 and close > Fib2;
def bullZone3 = state == state.long and close <= Fib2 and close > Fib3;
def bullZone4 = state == state.long and close <= Fib3 and close > TrailingStop;

def bearZone2 = state == state.short and close >= Fib1 and close < Fib2;
def bearZone3 = state == state.short and close >= Fib2 and close < Fib3;
def bearZone4 = state == state.short and close >= Fib3 and close < TrailingStop;

# watchlist
assignBackgroundColor(if state == state.long then Color.green else Color.red);
AddLabel(yes, if bullZone2 then "z2"  else if bullZone3 then "z3"  else if bullZone4 then "z4" else if bearZone2 then "z2"  else if bearZone3 then "z3"  else if bearZone4 then "z4" else " ",  if bullZone4 or bearZone4 then color.white else Color.BLACK);
 
@fishstick1229 This is why there are much more and better scripters than me around! Loving it!

It's working correctly on stocks, but not futures. Could you do a backtest on the different timeframes? can be 15m, 1h, 4h.

edit after realizing i'm such a klutz.
Remember to switch on extended hours watchlist for futures. Don't be a klutz like me!
 
Status
Not open for further replies.

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
209 Online
Create Post

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