Hi, this is my first post here, I am a newbie for Multicharts,
nice to meet all veteran.
I am facing coding problems during converting a Pine Script into Multicharts language.
The problems I guess is caused by linearRegValue, it shown error everytime:
"source: UI checker .........user interface of multicharts64.exe.......process is not responding..........."
The code is a essential indicator for me, it and I have found it's very useful, it cannot be absent in my trading.
"""This is a derivative of John Carter's "TTM Squeeze" volatility indicator, as discussed in his book "Mastering the Trade" (chapter 11).
Black crosses on the midline show that the market just entered a squeeze
( Bollinger Bands are with in Keltner Channel). This signifies low volatility , market preparing itself for an explosive move (up or down).
Gray crosses signify "Squeeze release"."""
here is the original code, link and description by LazyBear in TradingView.
https://www.tradingview.com/script/nqQ1 ... -LazyBear/
//
// @author LazyBear
// List of all my indicators:
// https://docs.google.com/document/d/15AG ... sp=sharing
// v2 - fixed a typo, where BB multipler was always stuck at 1.5. [Thanks @ucsgears]
//
study(shorttitle = "SMI", title="SMI", overlay=false)
length = input(20, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)
// Calculate BB
source = close
basis = sma(source, length)
dev = mult * stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev
// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = (sqzOn == false) and (sqzOff == false)
val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),
lengthKC,0)
bcolor = iff( val > 0,
iff( val > nz(val[1]), lime, green),
iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)
My version, however it's not working, calculating bollinger and Keltner Channel seems OK, but not the LinearRegValue:
//my version
var:length(0),mult(0),lengthkc(0),multkc(0);
length = 20;
mult = 2;
lengthkc =2;
multkc = 1.5;
//BB
var: basis(0), dev(0),upperbb(0),lowerbb(0);
basis = averagefc(close,length);
dev = mult* stddev(close,length);
upperbb = basis + dev;
lowerbb = basis - dev;
//plot1(basis,"",yellow);
plot2(upperbb,"",red);
plot3(lowerbb,"",red);
//KC
var: ma(0),rangex(0),rangema(0),upperkc(0),lowerkc(0);
ma = averagefc(close,lengthkc);
rangex = truerange;
rangema = averagefc(rangex,lengthkc);
upperkc = ma + (rangema*multkc);
lowerkc = ma - (rangema*multkc);
//plot4(rangema,"",yellow);
plot5(upperkc,"",blue);
plot6(lowerkc,"",blue);
//sqz on or off
condition1 = (lowerbb>lowerkc) and (upperbb<upperkc);
if condition1 then value1 = arw_new(date,time,close,false);
//linearregvalue
var:val(0),val2(0);
val2= close - average(average(highest(high, lengthkc), lowest(low, lengthkc)),average(close,lengthkc));
val = LinearRegvalue(val2,lengthkc,0);
plot7(val,"",yellow);
// Thanks to everyone, from my bottom of hearts, sorry for poor english//
converting useful Pine Script into Multicharts code
Re: converting useful Pine Script into Multicharts code
Hi,
Maybe you're mistakenly taking a moving average for a numerical average: Average( X, Y) is a different thing than (X+Y)/2
Try this instead:
Maybe you're mistakenly taking a moving average for a numerical average: Average( X, Y) is a different thing than (X+Y)/2
Try this instead:
Code: Select all
val2= close - AvgList( AvgList( highest(high, lengthkc), lowest(low, lengthkc) ), average(close,lengthkc) );
val = LinearRegvalue(val2,lengthkc,0);
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: converting useful Pine Script into Multicharts code
See post #1 and post #2
viewtopic.php?t=11713
viewtopic.php?t=11713
Re: converting useful Pine Script into Multicharts code
thanks so much!
I can finally plot an SMI line on multi charts now!
however, the line and number seems different to TradingView what I see
the SMI line in TradingView seems to have got kind of smoother,
and I really cannot tell the difference btw Mydesign's code and Lazybear's code.
what's the reason?
https://ibb.co/FzHCgMK
Mydesign's code:
LazyBear original code:
I can finally plot an SMI line on multi charts now!
however, the line and number seems different to TradingView what I see
the SMI line in TradingView seems to have got kind of smoother,
and I really cannot tell the difference btw Mydesign's code and Lazybear's code.
what's the reason?
https://ibb.co/FzHCgMK
Mydesign's code:
Code: Select all
var:length(0),mult(0),lengthkc(0),multkc(0);
length = 20;
mult = 2;
lengthkc =2;
multkc = 1.5;
//BB
var: basis(0), dev(0),upperbb(0),lowerbb(0);
basis = averagefc(close,length);
dev = mult* stddev(close,length);
upperbb = basis + dev;
lowerbb = basis - dev;
//plot1(basis,"",yellow);
//plot2(upperbb,"",red);
//plot3(lowerbb,"",red);
//KC
var: ma(0),rangex(0),rangema(0),upperkc(0),lowerkc(0);
ma = averagefc(close,lengthkc);
rangex = high-low;
rangema = averagefc(rangex,lengthkc);
upperkc = ma + (rangema*multkc);
lowerkc = ma - (rangema*multkc);
//plot4(rangema,"",yellow);
//plot5(upperkc,"",blue);
//plot6(lowerkc,"",blue);
//sqz on or off
condition1 = (lowerbb>lowerkc) and (upperbb<upperkc);
if condition1 then value1 = arw_new(date,time,close,false);
//linearregvalue
var:val(0),val2(0);
val2= close - AvgList( AvgList( highest(high, lengthkc), lowest(low, lengthkc) ), average(close,lengthkc) );
val = LinearRegvalue(val2,lengthkc,0);
plot7(val,"",yellow);
LazyBear original code:
Code: Select all
//
// @author LazyBear
// List of all my indicators:
// https://docs.google.com/document/d/15AGCufJZ8CIUvwFJ9W-IKns88gkWOKBCvByMEvm5MLo/edit?usp=sharing
// v2 - fixed a typo, where BB multipler was always stuck at 1.5. [Thanks @ucsgears]
//
study(shorttitle = "SMI", title="SMI", overlay=false)
length = input(20, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)
// Calculate BB
source = close
basis = sma(source, length)
dev = mult * stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev
// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = (sqzOn == false) and (sqzOff == false)
val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),
lengthKC,0)
bcolor = iff( val > 0,
iff( val > nz(val[1]), lime, green),
iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)
Re: converting useful Pine Script into Multicharts code
Make sure to use same parameters on both... but bear in mind that different datas may produce different results.
What is the "SMI" plot made of ? Is it "Val" from the code ?
What is the "SMI" plot made of ? Is it "Val" from the code ?
Re: converting useful Pine Script into Multicharts code
thanks!Make sure to use same parameters on both... but bear in mind that different datas may produce different results.
What is the "SMI" plot made of ? Is it "Val" from the code ?
yes, SMI means Val in the code