hi
- User
hi
- Assistant
Hello! How may I assist you?
- User
len = input(80, title='Length',group = 'Higher High-Lower Low / ZIGZAG') Depth = len Deviation = input.int(1, 'Deviation', minval=1, step=1, group = 'Higher High-Lower Low / ZIGZAG') Backstep = input.int(5, 'Backstep', minval=1, step=1, group = 'Higher High-Lower Low / ZIGZAG') on = input(true, 'HH-LL / ZIGZAG', group = 'Higher High-Lower Low / ZIGZAG') var last_h = 1 last_h += 1 var last_l = 1 last_l += 1 var lw = 1 var hg = 1 lw += 1 hg += 1 p_lw = -ta.lowestbars(Depth) p_hg = -ta.highestbars(Depth) lowing = lw == p_lw or low - low[p_lw] > Deviation * syminfo.mintick highing = hg == p_hg or high[p_hg] - high > Deviation * syminfo.mintick lh = ta.barssince(not highing[1]) ll = ta.barssince(not lowing[1]) down = ta.barssince(not(lh > ll)) >= Backstep lower = low[lw] > low[p_lw] higher = high[hg] < high[p_hg] if lw != p_lw and (not down[1] or lower) lw := p_lw < hg ? p_lw : 0 lw if hg != p_hg and (down[1] or higher) hg := p_hg < lw ? p_hg : 0 hg line zz = na line rs = na line sp = na label point = na x1 = down ? lw : hg y1 = down ? low[lw] : high[hg] if down == down[1] if on line.delete(zz[1]) label.delete(point[1]) down if down != down[1] if down last_h := hg last_h else last_l := lw last_l
if on zz := line.new(bar_index - (down ? last_h : last_l), down ? high[last_h] : low[last_l], bar_index - x1, y1, style=line.style_solid, width=1, color=down ? color.new(color.red,transp=50) : color.new(color.green,transp=50)) point := label.new(bar_index - x1, y1, down ? low[x1] < low[last_l] ? 'LL' : 'HL' : high[x1] > high[last_h] ? 'HH' : 'LH', style=down ? label.style_label_up : label.style_label_down, size=size.small, color=down ? color.new(color.black, 0) : color.new(color.black, 0), textcolor=color.white, tooltip=down ? low[x1] < low[last_l] ? 'Lower Low' : 'Higher Low' : high[x1] > high[last_h] ? 'Higher High' : 'Lower High') point
- Assistant
It looks like you've provided some code related to a strategy using zigzag indicators. Can you please clarify if you need any specific assistance with this code or if you have any questions related to zigzag indicators?
- User
i wanna same this code write by simple way pin script language
- Assistant
Sure, I can help with that. Here is the simplified code for the zigzag indicator using Pine Script:
//@version=4 study(title="Zigzag Indicator", shorttitle="Zigzag", format=format.price, precision=2, resolution="") len = input(title='Length', defval=10) dev = input(title='Deviation', defval=1) backstep = input(title='Backstep', defval=5) source = input(close, title='Source') var lastHigh = 0.0 var lastLow = 0.0 var lastHHBar = 0 var lastLLBar = 0 var lastDirectionUp = true zigzag(bar_source, len, dev, backstep) => currentDirectionUp = lastHigh <= lastLow currentExtreme = currentDirectionUp ? lastLow : lastHigh extremeBar = currentDirectionUp ? lastLLBar : lastHHBar newExtreme = bar_source - currentExtreme >= dev * syminfo.mintick newExtreme |= extremeBar == 0 newExtreme |= extremeBar + backstep >= bar_index if newExtreme if currentDirectionUp lastLow := bar_source lastLLBar := bar_index else lastHigh := bar_source lastHHBar := bar_index lastDirectionUp := currentDirectionUp currentExtreme zigzag(source, len, dev, backstep) plot(lastDirectionUp ? lastLow : lastHigh, color=color.green, style=plot.style_linebr, title='Zigzag')I hope this helps! Let me know if you have any further questions.
- User
len = input(80, title='Length',group = 'Higher High-Lower Low / ZIGZAG') Depth = len Deviation = input.int(1, 'Deviation', minval=1, step=1, group = 'Higher High-Lower Low / ZIGZAG') Backstep = input.int(5, 'Backstep', minval=1, step=1, group = 'Higher High-Lower Low / ZIGZAG') on = input(true, 'HH-LL / ZIGZAG', group = 'Higher High-Lower Low / ZIGZAG') var last_h = 1 last_h += 1 var last_l = 1 last_l += 1 var lw = 1 var hg = 1 lw += 1 hg += 1 p_lw = -ta.lowestbars(Depth) p_hg = -ta.highestbars(Depth) lowing = lw == p_lw or low - low[p_lw] > Deviation * syminfo.mintick highing = hg == p_hg or high[p_hg] - high > Deviation * syminfo.mintick lh = ta.barssince(not highing[1]) ll = ta.barssince(not lowing[1]) down = ta.barssince(not(lh > ll)) >= Backstep lower = low[lw] > low[p_lw] higher = high[hg] < high[p_hg] if lw != p_lw and (not down[1] or lower) lw := p_lw < hg ? p_lw : 0 lw if hg != p_hg and (down[1] or higher) hg := p_hg < lw ? p_hg : 0 hg line zz = na line rs = na line sp = na label point = na x1 = down ? lw : hg y1 = down ? low[lw] : high[hg] if down == down[1] if on line.delete(zz[1]) label.delete(point[1]) down if down != down[1] if down last_h := hg last_h else last_l := lw last_l
if on zz := line.new(bar_index - (down ? last_h : last_l), down ? high[last_h] : low[last_l], bar_index - x1, y1, style=line.style_solid, width=1, color=down ? color.new(color.red,transp=50) : color.new(color.green,transp=50)) point := label.new(bar_index - x1, y1, down ? low[x1] < low[last_l] ? 'LL' : 'HL' : high[x1] > high[last_h] ? 'HH' : 'LH', style=down ? label.style_label_up : label.style_label_down, size=size.small, color=down ? color.new(color.black, 0) : color.new(color.black, 0), textcolor=color.white, tooltip=down ? low[x1] < low[last_l] ? 'Lower Low' : 'Higher Low' : high[x1] > high[last_h] ? 'Higher High' : 'Lower High') point
- Assistant
Here's a simplified version of the code you provided:
//@version=4 study(title='Zigzag Indicator', shorttitle='Zigzag', group='Higher High-Lower Low / ZIGZAG') depth=input(title='Depth', defval=80, group='Higher High-Lower Low / ZIGZAG') deviation=input(title='Deviation', defval=1, minval=1, step=1, group='Higher High-Lower Low / ZIGZAG') backstep=input(title='Backstep', defval=5, group='Higher High-Lower Low / ZIGZAG') on=input(title='HH-LL / ZIGZAG', defval=true, group='Higher High-Lower Low / ZIGZAG') lastHigh=0.0 lastLow=0.0 lastHighBar=0 lastLowBar=0 lastDirectionIsUp=true zigzag(source, len, deviation, backstep)=> var lastSwing = 0.0 var lastSwingBar = 0 var newHigh = 0.0 var newLow = 0.0 isSwingHigh = source > lastSwing[1] and source >= lastSwingBar or (lastDirectionIsUp and lastSwingBar != 0 and lastSwing[1] - source > deviation * syminfo.mintick) isSwingLow = source < lastSwing[1] and source <= lastSwingBar or (not lastDirectionIsUp and lastSwingBar != 0 and source - lastSwing[1] > deviation * syminfo.mintick) lastSwing := isSwingHigh ? source : lastSwing[1] lastSwing := isSwingLow ? source : lastSwing[1] lastSwingBar := isSwingHigh or isSwingLow ? bar_index : lastSwingBar newHigh := isSwingHigh ? lastSwing : newHigh newLow := isSwingLow ? lastSwing : newLow [newHigh, newLow, lastSwingBar, lastSwing] [HH, LL, bar, price] = security(syminfo.tickerid, timeframe.period, zigzag(source, depth, deviation, backstep)) plot(zigzag(on ? HH : na, on ? LL : na)[0], color=color.green, style=plot.style_stepline) var line zz=label.new(na,na,"",color=color.white), label rs=label.new(na,na,"",color=color.white), label sp=label.new(na,na,"",color=color.white) var string text="" if bar!=bar[1] if lastDirectionIsUp?low[bar[1]]<=price:high[bar[1]]>=price lastDirectionIsUp:=not lastDirectionIsUp HH:=lastDirectionIsUp?HH:price LL:=lastDirectionIsUp?price:LL if on if not na(zz) label.delete(rs) label.delete(sp) label.set_xy(zz, bar_index, price) else zz:=label.new(bar_index,price,text,color=color.white)I hope this simplified version will work for you. Let me know if you have any further questions or concerns!
- User
HI
- Assistant
Hello! How may I assist you?
- User
CAN HELPE ME IN COING PIN SCRIPT FOR TRADING VIEW
- Assistant
Of course, I'd be happy to help! What would you like to have in your Pine Script code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →