Developing Gauss indicator
Forums › ProRealTime English forum › ProBuilder support › Developing Gauss indicator
- This topic has 16 replies, 3 voices, and was last updated 2 years ago by Zigo.
-
-
11/25/2021 at 4:01 AM #182236
I’m looking for some kind of Gaussian indicator (normal distribution).
There has been a lot of talk about it on the PRT forum, for example by @Bard, but no real indicator has yet emerged from it.
Perhaps it is possible, with the help of everyone who is interested in this, to shape this indicator.
The basic shape comes from a negatively squared exponent:
f(x) = e ^ (- x ^ 2)
By adding a variable mean and the standard deviation, the “complete” normal distribution is created.
f(x) = 1 / (σ√2π) exp ( -1/2 [ (x-μ) / σ ] ² )
The first challenge will be to program this complex formula in ProBuilder 🙂
11/25/2021 at 4:05 AM #18223711/25/2021 at 5:06 PM #182274It is an exponential function with the base e (2.7183), the base of the natural logarithm. This function is standard in PRT as Exp(a) so Exp(1) = e
Pi (π) = 3,1416
Sigma (σ) = Std[n](Close)
Mu (μ) = Close
f(x) = 1 / (Std[n](Close) * √ 6,2832) * Exp(-1 * (x – Close) ² / 2 * (Std[n](Close)) ²)
12/06/2021 at 1:49 PM #182878All,
12345678<span class="Y2IQFc" lang="en">I have modified the "Quino Statistics Plotter" indicator created last August,to map the theoretical Gaussian curve to a distribution of "Close" on a defined number of bars.This allows to have an idea if this distribution (Price) has the contours of a Gaussian curve<a class="gdbbx-bbcode-attachment" target="_blank" title="Quino-Statistics-Plotter-V3" href="https://a2a3f5h6.rocketcdn.me/wp-content/uploads/2021/12/Quino-Statistics-Plotter-V3.itf">Quino-Statistics-Plotter-V3</a>.See the old version in the indicator library for more information on the other functionalities.</span>// Quino Statistics Plotter
// By Quino
// version of 05/12/2021
//===================================================================================
// NbrOfSamples : Number of consecutive close
// NbrOfClasses : Number of intervals of values in which we store the values of “close”
// InformationDisplay :
// – false : display of the histogram only
// – true : display of limit values for each class and % of occurrence
// ClassTracer :
// – false : indicator that can be used stand-alone (curve and information)
// – true : indicator usable in the price indicator. By locating the class of the last “close” or another class. Class boundaries are represented by two horizontal lines on the price chart.
// ClassIndex : manual search for the class number corresponding to the last “close” or another class. Alignment of the cue point under the value of the last close (in red)
// GaussianShape
// – false : No Gaussian curve drawn
// – true : Gaussian curve drawn from avrerage and standard deviation of the selected number of consecutive close//Typical use : NbrOfSamples=150 ; NbrOfClasses=30 (5 samples per class minimum)
//===================================================================================
NbrMaxFrequency=1000 // Number max of occurency per class
AdjustA=30 // Scale calibration
AdjustB=4 // Position calibration
//———————————-
if islastbarupdate then
for k =0 to NbrOfSamples-1 do
$v[k]=close[k]
next
for i= NbrOfSamples-1 downto 0 do
$d[i]=arraymax($v)
for j=NbrOfSamples-1 downto 0 do
if $v[j]=$d[i] then
$v[j]=0
break
endif
next
next
Bin=(arraymax($d)-arraymin($d))/(NbrOfClasses)
For i=0 to NbrOfClasses do
$r[i]=0
next
BinA=arraymin($d)
for j=0 to NbrOfClasses-1 do
Dtemp=0
for i=0 to NbrOfSamples-1 do
if j < NbrOfClasses then
if $d[i]>=BinA+ j*Bin and $d[i] <BinA+(j+1)*Bin then
Dtemp=Dtemp+1
else
if $d[i]>=BinA+ j*Bin and $d[i] =<BinA+(j+1)*Bin then
Dtemp=Dtemp+1
endif
endif
endif
next
$r[j]=Dtemp
next
Vmoy=average[NbrOfSamples](close)
Vect=std[NbrOfSamples](close)
for k =0 to NbrOfClasses-1 do
$Vg[k]=((exp(-0.5*square(((BinA+ k*Bin)-Vmoy)/Vect)))/Vect*sqr(6.18))
next
if GaussianShape Then
Scale=max(arraymax($r),arraymax($Vg))+12
else
Scale=arraymax($r)+12
endif
If scale < AdjustA then
CorrecYY=1
CorrecY=1
endif
For i=1 to (NbrMaxFrequency/AdjustA) do
if scale>=i*AdjustA and scale<(i+1)*AdjustA then
CorrecYY=i+1
CorrecY=(i+1)*AdjustA/AdjustB
endif
next
for i= 0 to NbrOfClasses-1 do
if ClassTracer then
ValCaseMax=(BinA+ClassIndex*Bin)
ValCaseMin=(BinA+(ClassIndex-1)*Bin)
drawsegment(barindex[NbrOfSamples-1-i],ValCaseMax,barindex[NbrOfClasses-i-1],ValCaseMax)coloured (51,153,255)
drawsegment(barindex[NbrOfSamples-1-i],ValCaseMin,barindex[NbrOfClasses-i-1],ValCaseMin)coloured (0,51,153)
if i=ClassIndex then
tag=1
else
tag=undefined
endif
else
drawsegment(barindex[NbrOfClasses-i],$r[i],barindex[NbrOfClasses-i],0)coloured (0,0,0)
drawsegment(barindex[NbrOfClasses-i],$r[i],barindex[NbrOfClasses-i+1],$r[i])coloured (0,0,0)
drawsegment(barindex[NbrOfClasses-i+1],0,barindex[NbrOfClasses-i+1],$r[i]) coloured (0,0,0)
drawpoint(barindex[NbrOfClasses-ClassIndex+1],tag)coloured (0,0,50)
if GaussianShape then
drawsegment(barindex[NbrOfClasses-i+1],$Vg[i],barindex[NbrOfClasses-i],$Vg[i+1])coloured (255,0,0)
endif
if InformationDisplay then
for i= 0 to NbrOfClasses-1 do
temp=round(($r[i]/(NbrOfSamples))*10000)/100
temp1=round((BinA+(i)*Bin),2)
temp2=round((BinA+(i+1)*Bin),2)
drawtext(“%= #temp#”,barindex[NbrOfClasses-i],Scale+CorrecY-2*CorrecYY)coloured (0,0,255)
if close >= temp1 and close < temp2 then
drawtext(“#temp1#”,barindex[NbrOfClasses-i],Scale+CorrecY-6*CorrecYY)coloured (255,0,0)
drawtext(“#temp2#”,barindex[NbrOfClasses-i],Scale+CorrecY-4*CorrecYY)coloured (255,0,0)
else
drawtext(“#temp1#”,barindex[NbrOfClasses-i],Scale+CorrecY-6*CorrecYY)coloured (0,0,0)
drawtext(“#temp2#”,barindex[NbrOfClasses-i],Scale+CorrecY-4*CorrecYY)coloured (0,0,0)
endif
next
drawtext(“Average= #Vmoy#”,barindex-4,Scale-8*CorrecYY)coloured (0,0,0)
drawtext(“STD= #Vect#”,barindex-4,Scale-10*CorrecYY)coloured (0,0,0)
endif
endif
next
endif
if GaussianShape Then
Scale=max(arraymax($r),arraymax($Vg))+12+CorrecY
else
Scale=arraymax($r)+12+CorrecY
endif
if not ClassTracer then
zero=0
else
zero=undefined
Scale=undefined
endif
return Scale as “Vertical Reference”,zero as “Zero”123<span class="Y2IQFc" lang="en"><a class="gdbbx-bbcode-attachment" target="_blank" title="Quino-Statistics-Plotter-V3" href="https://a2a3f5h6.rocketcdn.me/wp-content/uploads/2021/12/Quino-Statistics-Plotter-V3.itf">Quino-Statistics-Plotter-V3</a></span>1 user thanked author for this post.
12/06/2021 at 3:49 PM #182886Hi @Quino
Thanks for sharing, good work.
I tried to program the theoretical Gaussian but ran into a scaling problem.
The theoretical Gaussian is (only) fixed by the mean (Close) and the standard deviation.
Do you think it is possible to shape this as shown in the posted example?
Regards JS
12/06/2021 at 5:42 PM #182898Hello JS,
12345678<span class="Y2IQFc" lang="en">If you refer to the example of <a class="bbp-user-mention bbp-user-id-464" href="https://www.prorealcode.com/user/bard">@Bard</a> with the Gaussian curve on the Y axis and compare it with the price curve,you cannot extract any statistical information.To calculate a statistic following a Gaussian distribution from the mean and the standard deviation,you do have to construct the histogram of your series of price "e.g : close" and compare the two shapes of the curves.If your histogram follows the theoretical Gaussian curve, then you can do a statistical calculation.If your histogram is different from the theoretical Gaussian curve, then you cannot do this calculation.(I don't speak about the goodness of fit. It is another history)The indicator I have created, allows this comparison of curve shapes to be made on any trading supports</span>12/06/2021 at 5:50 PM #182901Hello JS
If you refer to the example of @Bard with the Gaussian curve on the Y axis and compare it with the price curve,
you cannot extract any statistical information.
To calculate a statistic following a Gaussian distribution from the mean and the standard deviation,
you do have to construct the histogram of your series of price “e.g : close” and compare the two shapes of the curves.
If your histogram follows the theoretical Gaussian curve, then you can do a statistical calculation.
If your histogram is different from the theoretical Gaussian curve, then you cannot do this calculation.
(I don’t speak about the goodness of fit. It is another history)
The indicator I have created, allows this comparison of curve shapes to be made on any trading supportsSorry with the issues wih my text
12/06/2021 at 5:57 PM #18290212/06/2021 at 8:49 PM #182911Maybe I wasn’t entirely clear in my explanation but what I mean:
- Calculate/determine the standard deviation of the price over a certain period of time.
- Take the current Close as the average (mu).
- Enter 1 and 2 in the Gaussian formula.
- Plot the theoretical Gaussian as in the example.
Do you think that’s possible for programming?
12/07/2021 at 8:40 AM #182916Hi JS,
Maybe it’s possible to do it.
It calls a new developement. Not easy to do it.
If I undersand your need, I suggest to use the Bollinger Bands indicator that perform a price analysis from the mean and the SD.
This indicator don’t care if the price curve is a Gausssian distribution or not.
As it is popular in the trading world, il has some interesting properties.1 user thanked author for this post.
12/07/2021 at 3:27 PM #18294712/07/2021 at 3:32 PM #182949123456789a=(high+low)/2aa=Average[24](a)b=STD[10](a)cl=closey1=a+1/(b*SQRT(44/7))*exp(-1*(SQUARE((cl[n]-aa)))/2*square(b))y2=a-1/(b*SQRT(44/7))*exp(-1*(SQUARE((cl[n]-aa)))/2*square(b))return y1, y21 user thanked author for this post.
12/07/2021 at 5:03 PM #18296112/07/2021 at 11:35 PM #182975Hi @Quino
The problem with BB, in a non-stationary process, is that the (slowly) changing mean interferes with the calculation of the standard deviation.
Now that we have Pearson 🙂 you can see that the correlation with the price is going to vary due to the changing average.
12/08/2021 at 7:07 AM #182978 -
AuthorPosts
Find exclusive trading pro-tools on