Support Board
Date/Time: Sun, 15 Jun 2025 07:07:41 +0000
[Programming Help] - pinescript code conversion
View Count: 273
[2025-06-02 20:07:28] |
User411320 - Posts: 331 |
Hello everyone, I'm trying to convert a code in pinescript to sierra utilizing the spreadsheet but not getting the same results. can anyone help?
|
[2025-06-03 01:36:17] |
cmet - Posts: 706 |
Can you post the PS code?
|
[2025-06-03 12:24:10] |
User411320 - Posts: 331 |
// Input Groups var string apz_settings = "════════ APZ Settings ════════" var string visual_settings = "════════ Visualization Settings ════════" // Descriptions for inputs (Tooltips) tooltip_apz_length = "Length of the APZ calculation period. Higher values create smoother signals but respond slower to price changes." tooltip_threshold = "Multiplier for volatility bands. Higher values create wider bands and generate fewer signals." tooltip_smooth = "Smoothing period for the typical price. Higher values reduce noise but increase lag." tooltip_bar_coloring = "Enable or disable bar coloring based on trend direction." // APZ Settings length = input.int(21, "APZ Length", minval=1, group=apz_settings, tooltip=tooltip_apz_length) threshold = input.float(2.0, "Threshold", minval=0.1, step=0.1, group=apz_settings, tooltip=tooltip_threshold) smooth = input.int(5, "Smoothing", minval=1, group=apz_settings, tooltip=tooltip_smooth) // Visualization Settings bullcolor = input.color(#00ffaa, "Bullish Color", group=visual_settings) bearcolor = input.color(#ff0000, "Bearish Color", group=visual_settings) bar = input.bool(false, "Color Bars?", group=visual_settings, tooltip=tooltip_bar_coloring) // ╔════════════════════════════════╗ // // ║ APZ CALCULATIONS ║ // // ╚════════════════════════════════╝ // // Price and volatility calculations float typical = hlc3 float volatility = ta.ema(math.abs(typical - typical[1]), length) float upperBand = ta.ema(typical, smooth) + threshold * volatility float lowerBand = ta.ema(typical, smooth) - threshold * volatility // Trend Detection and APZ Calculation float trend = 0 trend := typical > upperBand[1] ? 1 : typical < lowerBand[1] ? -1 : nz(trend[1]) // ╔════════════════════════════════╗ // // ║ VISUALIZATION ║ // // ╚════════════════════════════════╝ // // Bullish/Bearish Trend l1 = plot(1, "Bullish Trend", display=display.none, color=color.new(bullcolor, 0)) l2 = plot(-1, "Bearish Trend", display=display.none, color=color.new(bearcolor, 30)) // Neutral Line hline(0, color=color.new(color.white, 50), title="Zero Line") // APZ Trend Plot z = plot(trend, "APZ Trend", trend > 0 ? bullcolor : bearcolor, linewidth=4, style=plot.style_stepline_diamond) mid = plot(0, color=color.new(color.white, 50), display=display.none) // Fill between trend and zero line fill(z, mid, trend > 0 ? trend : 0, trend > 0 ? 0 : trend, trend > 0 ? color.new(bullcolor, 10) : na, trend > 0 ? na : color.new(bearcolor, 10)) // Signal Markers plotshape(ta.crossover(trend, 0), location = location.belowbar, style = shape.triangleup, size = size.tiny, text = "⤻", textcolor = chart.fg_color, color = bullcolor, title = "Mean Reversion Up", force_overlay = true ) plotshape(ta.crossunder(trend, 0), location = location.abovebar, style = shape.xcross, size = size.tiny, text = "↷", textcolor = chart.fg_color, color = bearcolor, title = "Mean Reversion Down", force_overlay = true ) barcolor(bar ? trend > 0 ? bullcolor : bearcolor : na) |
[2025-06-03 12:25:24] |
User411320 - Posts: 331 |
this is the formula I have for the signals but I'm doing something wrong somewhere because I'm not getting the same result
Date Time Of Last Edit: 2025-06-03 12:25:39
|
![]() |
[2025-06-03 13:23:58] |
cmet - Posts: 706 |
Do you have the APZ study converted? Are you just trying to pull the signals off the binary oscillator?
|
[2025-06-03 14:11:36] |
User411320 - Posts: 331 |
I'm trying to convert it
|
[2025-06-03 15:01:26] |
cmet - Posts: 706 |
Not a fan of spreadsheets but if you want to use a custom study, here's one. For signals you can use Color Bar Based on Alert Condition. Long: AND(ID1.SG1 = 1, ID1.SG1[-1] = -1) Short: AND(ID1.SG1 = -1, ID1.SG1[-1] = 1) |
![]() |
[2025-06-03 16:52:07] |
User411320 - Posts: 331 |
wow thank you. I was trying to figure it out on spreadsheet since I can't code. Can I DM you? or do you gave a twitter name?
|
To post a message in this thread, you need to log in with your Sierra Chart account: