Moxie indicator conversion
Forums › ProRealTime English forum › ProBuilder support › Moxie indicator conversion
- This topic has 8 replies, 4 voices, and was last updated 1 month ago by
JC_Bywan.
Tagged: moxie
-
-
04/22/2021 at 4:57 AM #167742
I am just wandering if anyone could help to convert moxie indicator and scanner from TOS (think of swim) to PRT.
Code as below
indicator
123# ST_Moxie_Hourly Indicatordeclare lower;DefineGlobalColor("UpTrend", Color.GREEN);DefineGlobalColor("DownTrend", Color.RED);DefineGlobalColor("NoTrend", Color.LIGHT_GRAY);def hP1a = AggregationPeriod.Day;def s5v = 12;def ul = Average( High * (1 + 4 * (High - Low) / (High + Low)), length = 14);def s5r = 26;def s5g = 9;def vc1 = ExpAverage(close(period = hP1a) , s5v) - ExpAverage(close(period = hP1a) , s5r);def m2 = AbsValue((close - Lowest(low, s5r)) - (Highest(high, s5g) - close)) / (Highest(high, s5g) - Lowest(low, s5g));def va1 = ExpAverage(vc1, s5g);plot Moxie = (vc1 - va1) * 3; def g1 = Cos(1.32 * 2 * Double.Pi / (s5g / 0.1));Moxie.SetStyle(Curve.FIRM);Moxie.SetLineWeight(2);Moxie.HideTitle();def l1 = Moxie < Moxie[1];def h1 = Moxie > Moxie[1];def sig = if l1 then yes else if sig[1] == yes and h1 == no then yes else no;Moxie.AssignValueColor(if sig then Color.RED else Color.UPTICK);plot zeroLine = if close[-1] > 0 then 0 else Double.NaN;zeroLine.setDefaultColor(Color.gray);zeroLine.SetStyle(Curve.FIRM);zeroLine.SetLineWeight(2);zeroLine.HideBubble();zeroLine.HideTitle();Trade Signal
123# ST_MoxiePriceSignal_Hourlydef hP1a = AggregationPeriod.Day;def s5v = 12;def ul = Average( High * (1 + 4 * (High - Low) / (High + Low)), length = 14);def s5r = 26;def s5g = 9;def vc1 = ExpAverage(close(period = hP1a) , s5v) - ExpAverage(close(period = hP1a) , s5r);def m2 = AbsValue((close - Lowest(low, s5r)) - (Highest(high, s5g) - close)) / (Highest(high, s5g) - Lowest(low, s5g));def va1 = ExpAverage(vc1, s5g);def Moxie = (vc1 - va1); plot crossingAbove = if Moxie[1] < 0 and Moxie > 0 then low(period = AggregationPeriod.DAY) else Double.NaN;plot crossingBelow = if Moxie[1] > 0 and Moxie < 0 then high(period = AggregationPeriod.DAY) else Double.NaN;crossingAbove.SetDefaultColor(Color.GREEN);crossingAbove.SetPaintingStrategy(PaintingStrategy.ARROW_UP);crossingBelow.SetDefaultColor(Color.RED);crossingBelow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);Scanner
123# ST_Moxie_Scan Scannerdeclare lower;def s5v = 12;def ul = Average( High * (1 + 4 * (High - Low) / (High + Low)), length = 14);def s5r = 26;def s5g = 9;def vc1 = ExpAverage(close , s5v) - ExpAverage(close , s5r);def m2 = AbsValue((close - Lowest(low, s5r)) - (Highest(high, s5g) - close)) / (Highest(high, s5g) - Lowest(low, s5g));def g1 = Cos(1.32 * 2 * Double.Pi / (s5g / 0.1));def va1 = ExpAverage(vc1, s5g);plot MoxieScan = ((vc1 - va1) * 3) > 0;04/22/2021 at 9:47 AM #16777104/23/2021 at 2:40 PM #16790004/23/2021 at 3:47 PM #167906Here is the translated code of Moxie indicator. Apply it twice, on the price chart in order to see the arrows of the trading signals and separated as an oscillator. Lot of useless code have been wiped out. This indicator seems to be a daily normalized MACD.
12345678910111213141516171819202122232425262728293031//# ST_Moxie_Hourly Indicators5v = 12s5r = 26s5g = 9timeframe(daily,updateonclose)vc1 = ExponentialAverage[s5v](close) - ExponentialAverage[s5r](close)m2 = Abs((close - Lowest[s5r](low)) - (Highest[s5g](high) - close)) / (Highest[s5g](high) - Lowest[s5g](low))va1 = ExponentialAverage[s5g](vc1)Moxie = (vc1 - va1) * 3l1 = Moxie < Moxie[1]h1 = Moxie > Moxie[1]//sig =if l1 thenr=255g=0elsif h1 thenr=0g=255endiftimeframe(default)if moxie crosses over 0 thendrawarrowup(barindex,low) coloured(r,g,0)elsif moxie crosses under 0 thendrawarrowdown(barindex,high) coloured(r,g,0)endifreturn Moxie coloured(r,g,0) style(line,2),0 coloured(168,168,168) style(line,2)04/23/2021 at 7:09 PM #16791404/26/2021 at 1:29 PM #168066Apply it twice, on the price chart in order to see the arrows of the trading signals and separated as an oscillator.
Just follow the instruction ^^ 🙄
06/10/2025 at 7:04 AM #248132Hi Nicolas,
I have tried to use this code for Trading View. Do I require any ammendments in order for it to work?
Currently get this error
The Pine version of this script is unspecified, so it will compile as Pine v1. To use another version of Pine, add ‘//@version={versionNumber}’ to the top of the script. E.g., ‘//@version=5’ for Pine v5.ps – I am no coder06/10/2025 at 7:25 AM #248133update: used chatgpt
gave me this code
//@version=5
indicator(“ST_Moxie_Hourly”, overlay=false)// === Input Parameters ===
s5v = input.int(12, “Short EMA”, minval=1)
s5r = input.int(26, “Long EMA”, minval=1)
s5g = input.int(9, “Signal EMA”, minval=1)
scaleFactor = input.int(1000, “Visual Scale”, minval=1) // Adjust for asset// === Moxie Calculations ===
vc1 = ta.ema(close, s5v) – ta.ema(close, s5r)
va1 = ta.ema(vc1, s5g)
moxieRaw = vc1 – va1
moxie = moxieRaw * scaleFactor// === Color Based on Trend Direction ===
isUp = moxie > moxie[1]
isDown = moxie < moxie[1]
moxieColor = isUp ? color.green : isDown ? color.red : color.gray// === Line Plot ===
plot(moxie, title=”Moxie Line”, style=plot.style_line, color=moxieColor, linewidth=2)// === Reference Line ===
hline(0, “Zero Line”, color=color.gray, linewidth=1)It doesnt look like the original, unsure why. However do you think this is okay? Not got the arrows on the graph and I see you say paste it twice but that does not work and creates an error.
Also, can this code be used for any time frame or just the one hour? Do I need to make ammendemnets to it so I can switch between time frames and the data is still correct? cheers06/14/2025 at 6:26 AM #248266Hello @jamjamjam,
Conversion of codes from Tradingview or another platform towards ProRealTime language would be free on the forums of this ProRealCode website dedicated to ProRealTime. But conversion of a ProRealTime code into a language compatible with tradingview would be a paid-for private job rather than a forum free discussion, for which you may ask for a quote in the “trading programming services” section of the PRC website, available in the help menu at the top of current page. Direct link:
https://www.prorealcode.com/trading-programming-services/
-
AuthorPosts
Find exclusive trading pro-tools on