Swings high/low indicator with volume and points for futures

Ajx98

New member
Hello,
Is it possible to create a swing indicator on a 1 min chart identifying highs and lows indicating what was the total points move and the volume traded during that swing. I think its available on some other platform that I saw. example image attached
https%3A//i.imgur.com/MjCyu4Z.png[/img]']
MjCyu4Z.png


The swings in this case are colored red and blue. We can also see the number of ticks/points moved in a swing and the total volume in that move.
Red - A downswing with more volume than the prior upswing OR an upswing with less volume than the prior downswing.
Blue - An upswing with more volume than the prior downswing OR a downswing with less volume than the prior upswing.
As long as the volume is greater on the moves up, the swings will be blue. Vice versa for reds. Thanks in advance for helping!
 
Solution
Hello,
Is it possible to create a swing indicator on a 1 min chart identifying highs and lows indicating what was the total points move and the volume traded during that swing. I think its available on some other platform that I saw. example image attached
https%3A//i.imgur.com/MjCyu4Z.png[/img]']
MjCyu4Z.png


The swings in this case are colored red and blue. We can also see the number of ticks/points moved in a swing and the total volume in that move.
Red - A downswing with more volume than the prior upswing OR an upswing with less volume than the prior downswing.
Blue - An upswing with more volume than the prior downswing OR a downswing with less volume than the prior upswing.
As long as the volume is greater on the moves up, the...
Hello,
Is it possible to create a swing indicator on a 1 min chart identifying highs and lows indicating what was the total points move and the volume traded during that swing. I think its available on some other platform that I saw. example image attached
https%3A//i.imgur.com/MjCyu4Z.png[/img]']
MjCyu4Z.png


The swings in this case are colored red and blue. We can also see the number of ticks/points moved in a swing and the total volume in that move.
Red - A downswing with more volume than the prior upswing OR an upswing with less volume than the prior downswing.
Blue - An upswing with more volume than the prior downswing OR a downswing with less volume than the prior upswing.
As long as the volume is greater on the moves up, the swings will be blue. Vice versa for reds. Thanks in advance for helping!

You may find this zigzag code useful that I did in part quite awhile ago when I was first learning scripting. It has alot of options at the input screen for you to choose to display. This is a repainting indicator, meaning the pivots can disappear if the future bars do not support the pivot. I used the average option to lessen the repainting. In the image is the barcount, volume and change at each pivot.

Capture.jpg
Ruby:
#TOS version ZigZagHighLow modified in part by Linus' and Lar's code
input method = {default average, high_low};
input bubbleoffset = .001;
input percentamount = .01;
input revAmount = .05;
input atrreversal = 3.0;
input atrlength = 5;
input pricehigh = high;
input pricelow  = low;
input averagelength = 5;
input averagetype = AverageType.EXPONENTIAL;
def mah = MovingAverage(averagetype, pricehigh, averagelength);
def mal = MovingAverage(averagetype, pricelow, averagelength);
def priceh = if method == method.high_low then pricehigh else mah;
def pricel = if method == method.high_low then pricelow else mal;
def zz = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = percentamount, "absolute reversal" = revAmount, "atr length" = atrlength, "atr reversal" = atrreversal);
def reversalAmount        = if (close * percentamount / 100) > Max(revAmount < atrreversal * reference ATR(atrlength), revAmount) then (close * percentamount / 100) else if revAmount < atrreversal * reference ATR(atrlength) then atrreversal * reference ATR(atrlength) else revAmount;
rec zzSave = if !IsNaN(zz) then zz else GetValue(zzSave, 1);
def chg = (if zzSave == priceh then priceh else pricel) - GetValue(zzSave, 1);
def isUp = chg >= 0;
rec isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue(zz, 1)) and GetValue(isConf, 1));
def zzd = if isUp then 1 else 0;
plot zzp = if zzd <= 1 then zz else Double.NaN;
zzp.AssignValueColor(if zzd == 1 then Color.GREEN else if zzd == 0 then Color.RED else Color.DARK_ORANGE);
zzp.SetStyle(Curve.FIRM);
zzp.EnableApproximation();
zzp.HideBubble();
#Price Change between zigzags
def xxhigh = if zzSave == priceh then  priceh else xxhigh[1];
def chghigh = priceh - xxhigh[1];
def xxlow = if zzSave == pricel then pricel else xxlow[1];
def chglow = pricel - xxlow[1];
input showBubbleschange = no;
AddChartBubble(showBubbleschange and !IsNaN(zz) and BarNumber() != 1, if isUp then priceh * (1 + bubbleoffset)  else pricel * (1 - bubbleoffset)   , "$" + astext(chg) , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, isUp);
#Price at High/Low
input showBubblesprice = no;
AddChartBubble(showBubblesprice and !IsNaN(zz) and BarNumber() != 1, if isUp then priceh * (1 + bubbleoffset)  else pricel * (1 - bubbleoffset)   , if isUp then "$" + priceh else "$" + pricel , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, isUp);
#Label for Confirmed/Unconfirmed Status of Current Zigzag
AddLabel(BarNumber() != 1, "ZZRev: " + chg + "Confirm@ " + Round(reversalAmount, 2), if !isConf then Color.DARK_ORANGE else if isUp then Color.GREEN else Color.RED);
#Daily ZigZag Range Total
rec counth =  if GetDay() == GetLastDay() and SecondsFromTime(0930) >= 0  then CompoundValue(1, if counth[1] == 0 and !IsNaN(chghigh) and  zzSave == pricehigh and zzSave != pricelow then AbsValue(chg) else if !IsNaN(chghigh) and (zzSave == pricehigh and  zzSave != pricelow) then  counth[1] + AbsValue(chg)  else counth[1], 0) else 0;
rec countl =  if GetDay() == GetLastDay() and SecondsFromTime(0930) >= 0  then CompoundValue(1, if countl[1] == 0 and !IsNaN(chglow) and  zzSave != pricehigh and zzSave == pricelow then AbsValue(chg) else if !IsNaN(chglow) and (zzSave != pricehigh and  zzSave == pricelow) then  countl[1] + AbsValue(chg)  else countl[1], 0) else 0;
AddLabel(yes, "ZZRange " + "$" + Round((counth + countl), 2), Color.GREEN);
#Bar Count between zigzags
def barnumber = BarNumber();
rec zzcount = if zzSave[1] != zzSave then 1 else if zzSave[1] == zzSave then zzcount[1] + 1 else 0;
def zzcounthilo   =  if zzcounthilo[1] == 0 and (zzSave == priceh or zzSave == pricel) then 1 else if zzSave == priceh or zzSave == pricel then zzcounthilo[1] + 1 else zzcounthilo[1];
def zzhilo = if zzSave == priceh or zzSave == pricel then zzcounthilo else zzcounthilo + 1;
def zzcounthigh = if zzSave == priceh then zzcount[1] else Double.NaN;
def zzcountlow =  if zzSave == pricel then zzcount[1] else Double.NaN;
input showBubblesbarcount = no;
AddChartBubble(showBubblesbarcount and !IsNaN(zz) and BarNumber() != 1, if isUp then priceh * (1 + bubbleoffset)  else pricel * (1 - bubbleoffset)  , if zzSave == priceh then zzcounthigh else zzcountlow, if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );
#Volume at Reversals
input showvolumewave = no;
def vol = if BarNumber() == 0 then 0 else volume + vol[1];
def vol1 = if BarNumber() == 1 then volume else vol1[1];
def xxvol = if zzSave == priceh or zzSave == pricel then TotalSum(volume) else xxvol[1];
def chgvol =  if xxvol - xxvol[1] + vol1 == vol then vol else xxvol - xxvol[1];
plot cvol = chgvol;
cvol.AssignValueColor( if isUp then Color.GREEN else Color.RED);
cvol.SetHiding(showvolumewave == no);
rec zzvol = if zzhilo[1] != zzhilo then 0 else zzvol[1] + volume;
plot zzvolupdn = if showvolumewave then zzvol else Double.NaN;
zzvolupdn.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
zzvolupdn.AssignValueColor(if  isUp then Color.GREEN else Color.RED);

rec volup   = if isUp then if close > open then volup[1] + volume else volup[1] else 0;
rec volup_  = if isUp then if close <= open then volup_[1] + volume else volup_[1] else 0;
def volup1  = if zzSave == priceh then volup - volup_ else Double.NaN;
rec voldn   = if !isUp then if close > open then voldn[1] + volume else voldn[1] else 0;
rec voldn_  = if !isUp then if close <= open then voldn_[1] + volume else voldn_[1] else 0;
def voldn1  = if zzSave == pricel then voldn - voldn_ else Double.NaN;
input show_net_volume = yes;
AddChartBubble(show_net_volume and !IsNaN(zz) and BarNumber() != 1, if isUp then priceh * (1 + bubbleoffset)  else pricel * (1 - bubbleoffset), "NV: " + if isUp then AbsValue(volup1) else AbsValue(voldn1), if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );

plot zzt = if showvolumewave then if zzSave == priceh or zzSave == pricel then chgvol else Double.NaN else Double.NaN;
zzt.EnableApproximation();
zzt.AssignValueColor( if isUp then Color.GREEN else Color.RED);
zzt.SetLineWeight(2);

AddChartBubble(showvolumewave and !IsNaN(zz) and barnumber != 1, chgvol , chgvol, if isUp then Color.GREEN else Color.RED, yes);

AddChartBubble(showvolumewave and !IsNaN(zz) and barnumber != 1, chgvol  , if zzSave == priceh then zzcounthigh else zzcountlow, if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.GREEN else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.RED, yes );
input showBubblesVolume = no;
AddChartBubble(showBubblesVolume and !IsNaN(zz) and BarNumber() != 1, if isUp then priceh * (1 + bubbleoffset)  else pricel * (1 - bubbleoffset), "ZV: " + chgvol, if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );
 
Solution
You may find this zigzag code useful that I did in part quite awhile ago when I was first learning scripting. It has alot of options at the input screen for you to choose to display. This is a repainting indicator, meaning the pivots can disappear if the future bars do not support the pivot. I used the average option to lessen the repainting. In the image is the barcount, volume and change at each pivot.
Is it possible to use this as BUY alert and SELL alert in 5-min. chart?.
 
Is it possible to use this as BUY alert and SELL alert in 5-min. chart?.
You can add this to the bottom of your script.
Because this is a repainting indicator, it will be alerting constantly as it is heading down and then heading back up.
# Alert
Alert(barnumber != 1 and isUp, "up alert", Alert.Bar, Sound.Chimes);
Alert(barnumber != 1 and !isUp, "up alert", Alert.Bar, Sound.Chimes);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
411 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