The indicators have been translated for a number of popular platforms.
What is Ninjatrader's policy regarding indicators published in TASC ? I have seen some TASC indicators coded in NT - and others are not coded.
TIA
WealthScript code (C#): { public class CoronaCharts : WealthScript { public const double twoPi = 2 * Math.PI; public const double fourPi = 4 * Math.PI; public class ArrayHolder { // current, old, older internal double I, I2, I3; internal double Q, Q2, Q3; internal double R, R2, R3; internal double Im, Im2, Im3; internal double A; internal double dB, dB2; } // Keep cntMax fifo samples and find the Highest and Lowest lead for samples in the list private void PhaseList(ref ArrayList fifo, int cntMax, double lead, out double H, out double L) { H = lead; L = lead; if( fifo.Count < cntMax ) fifo.Add(lead); else { fifo.RemoveAt(0); fifo.Add(lead); } for (int n = 0; n < fifo.Count - 1; n++) { double val = (double)fifo[n]; if( val > H ) H = val; if( val < L ) L = val; } } public void SuperIndicators(DataSeries ds, out DataSeries domCycMdn, out DataSeries snrSer, out DataSeries psnSer, out DataSeries tvSer) { // Initialize arrays ArrayHolder[] ah = new ArrayHolder[61]; for( int n = 12; n < 61; n++ ) ah[n] = new ArrayHolder(); double domCycle = 0d; string s = ds.Description + ")"; DataSeries[] DB = new DataSeries[61]; DataSeries domCyc = Close - Close; domCycMdn = domCyc * 0d; snrSer = domCycMdn + 0d; psnSer = snrSer + 0d; tvSer = psnSer + 0d; domCyc.Description = "DC(" + s; domCycMdn.Description = "DomCyc(" + s; snrSer.Description = "SNR(" + s; psnSer.Description = "Swing Position(" + s; tvSer.Description = "Trend Vigor(" + s; // Create and plot the decibel series - change the colors later ChartPane dbPane = CreatePane(40, false, false ); for( int n = 12; n < 61; n++ ) { double d = n / 2.0; DB[n] = domCyc + d; DB[n].Description = "Cycle." + d.ToString(); PlotSeries(dbPane, DB[n], Color.Black, LineStyle.Solid, 4); } DataSeries[] Raster = new DataSeries[51]; // SNR Corona chart ChartPane snrPane = CreatePane(40, false, false ); for( int n = 1; n < 51; n++ ) { double d = 1d + n / 5.0; Raster[n] = domCyc + d; Raster[n].Description = "SNR." + d.ToString(); PlotSeries(snrPane, Raster[n], Color.Black, LineStyle.Solid, 4); } DataSeries[] RasterSwg = new DataSeries[51]; // Swing Corona chart ChartPane swgPane = CreatePane(40, false, false ); for( int n = 1; n < 51; n++ ) { double d = 0.2 * n - 5.0; RasterSwg[n] = domCyc + d; RasterSwg[n].Description = "Swing." + d.ToString(); PlotSeries(swgPane, RasterSwg[n], Color.Black, LineStyle.Solid, 4); } DataSeries[] RasterTV = new DataSeries[51]; // Trend Vigor Corona chart ChartPane tvPane = CreatePane(40, false, false ); for( int n = 1; n < 51; n++ ) { double d = 0.4 * n - 10.0; RasterTV[n] = domCyc + d; RasterTV[n].Description = "TV." + d.ToString(); PlotSeries(tvPane, RasterTV[n], Color.Black, LineStyle.Solid, 4); } Color[] color = new Color[21]; // Convert decibels to RGB color for display for( int n = 0; n <= 10; n++ ) // yellow to red: 0 to 10 dB color[n] = Color.FromArgb(255, (int)(255 - (255 * n / 10)), 0); for( int n = 11; n <= 20; n++ ) // red to black: 11 to 20 db color[n] = Color.FromArgb( (int)(255 * (20 - n)/10 ), 0, 0); Color[] colorSNR = new Color[21]; // Corona chart SNR colors for( int n = 0; n <= 10; n++ ) { int c1 = 220 - ( 22 * n ); int c2 = 255 - ( 7 * n ); colorSNR[n] = Color.FromArgb(c1, c2, c2); } for( int n = 11; n <= 20; n++ ) { int c2 = (int)(190 * ( 2 - n/10d )); colorSNR[n] = Color.FromArgb(0, c2, c2); } Color[] colorSwg = new Color[21]; // Corona chart Swing colors for( int n = 0; n <= 10; n++ ) { int c1 = 180 - ( 18 * n ); int c2 = 255 - ( 8 * n ); int c3 = 210 - ( 15 * n ); colorSwg[n] = Color.FromArgb(c1, c2, c3); } for( int n = 11; n <= 20; n++ ) { int c2 = (int)(172 * ( 2 - n/10d )); int c3 = (int)(64 * ( 2 - n/10d )); colorSwg[n] = Color.FromArgb(0, c2, c3); } Color[] colorTV = new Color[21]; // Trend Vigor chart colors for( int n = 0; n <= 10; n++ ) { int c1 = 60 - ( 6 * n ); int c2 = 120 - ( 12 * n ); colorTV[n] = Color.FromArgb(c1, c2, 255); } for( int n = 11; n <= 20; n++ ) colorTV[n] = Color.FromArgb(0, 0, (int)(255 * ( 2 - n/10d )));
// Detrend data by High Pass Filtering with a 40 Period cutoff DataSeries HP = domCyc; double alpha = (1 - Math.Sin(twoPi/30)) / Math.Cos(twoPi/30); for(int bar = 1; bar < Bars.Count; bar++) HP[bar] = 0.5 * (1 + alpha)* Momentum.Series(ds, 1)[bar] + alpha * HP[bar-1]; DataSeries smoothHP = FIR.Series(HP, "1,2,3,3,2,1"); DataSeries hmlSer = Median.Series( High - Low, 5 ); double avg, signal, noise, snr; // Variables SNR double avg1 = 0d; double signal1 = 0d; double noise1 = 0d; const double delta2 = 0.1; // Variables Swing, TV double BP2_1 = 0d; double BP2_2 = 0d; double beta2, BP2, g2, alpha2, Q2, Lead60, HL, LL, widthSwg; ArrayList fifoList = new ArrayList(51); ArrayList fifoPsn = new ArrayList(21); double ratio = 0d; double ratio1 = 0d; double widthTV = 0d; // arrays to hold raster values from previous bar int[] raster2 = new int[51]; int[] raster2Swg = new int[51]; int[] raster2TV = new int[51]; for( int bar = 12; bar < Bars.Count; bar++ ) { double maxAmpl = 0d; double delta = -0.015 * bar + 0.5; delta = delta < 0.1 - 0.1 : delta; for( int n = 12; n < 61; n++ ) { double beta = Math.Cos(fourPi / n); double g = 1 / Math.Cos(2 * fourPi * delta / n); double a = g - Math.Sqrt(g * g - 1); ah[n].Q = Momentum.Series(smoothHP, 1)[bar] * n / fourPi; ah[n].I = smoothHP[bar]; ah[n].R = 0.5 * (1 - a) * (ah[n].I - ah[n].I3) + beta * (1 + a) * ah[n].R2 - a * ah[n].R3; ah[n].Im = 0.5 * (1 - a) * (ah[n].Q - ah[n].Q3) + beta * (1 + a) * ah[n].Im2 - a * ah[n].Im3; ah[n].A = ah[n].R * ah[n].R + ah[n].Im * ah[n].Im; maxAmpl = ah[n].A > maxAmpl - ah[n].A : maxAmpl; } double num = 0; double den = 0; for( int n = 12; n < 61; n++ ) { ah[n].I3 = ah[n].I2; ah[n].I2 = ah[n].I; ah[n].Q3 = ah[n].Q2; ah[n].Q2 = ah[n].Q; ah[n].R3 = ah[n].R2; ah[n].R2 = ah[n].R; ah[n].Im3 = ah[n].Im2; ah[n].Im2 = ah[n].Im; ah[n].dB2 = ah[n].dB; if( maxAmpl != 0 && ah[n].A / maxAmpl > 0 ) ah[n].dB = 10 * Math.Log10( (1 - 0.99 * ah[n].A / maxAmpl) / 0.01 ); ah[n].dB = 0.33 * ah[n].dB + 0.67 * ah[n].dB2; ah[n].dB = ah[n].dB > 20 - 20 : ah[n].dB; SetSeriesBarColor(bar, DB[n], color[(int)Math.Round(ah[n].dB)]); if( ah[n].dB <= 6 ) { num += n * (20 - ah[n].dB); den += (20 - ah[n].dB); } if( den != 0 ) domCycle = 0.5 * num / den; } domCycMdn[bar] = Median.Value(bar, domCyc, 5); domCycMdn[bar] = domCycle < 6 - 6: domCycle; // Calculate SNR this bar signal = 0d; noise = 0d; snr = 0d; avg = 0.1 * ds[bar] + 0.9 * avg1; if( avg != 0d || maxAmpl > 0 ) signal = 0.2 * Math.Sqrt(maxAmpl) + 0.9 * signal1; if( avg != 0d ) noise = 0.1 * hmlSer[bar] + 0.9 * noise1; if( signal != 0d || noise != 0d ) snr = 20 * Math.Log10(signal/noise) + 3.5; snr = snr < 1d - 0d : snr; snr = snr > 10d - 10d : snr; snr = snr * 0.1; snrSer[bar] = snr * 10 + 1; double Width = snr > 0.5 - 0d : -0.4 * snr + 0.2; // Calculate the Swing this bar beta2 = Math.Cos(twoPi / domCycMdn[bar]); g2 = 1 / Math.Cos(fourPi * delta2 / domCycMdn[bar]); alpha2 = g2 - Math.Sqrt(g2 * g2 - 1); BP2 = 0.5 * (1 - alpha2) * (ds[bar] - ds[bar-2]) + beta2 * (1 + alpha2) * BP2_1 - alpha2 * BP2_2; //Quadrature component is derivative of InPhase component divided by omega Q2 = (domCycMdn[bar] / twoPi) * (BP2 - BP2_1); Lead60 = 0.5 * BP2 + 0.866 * Q2; PhaseList(ref fifoList, 50, Lead60, out HL, out LL); double Psn = (Lead60 - LL) / (HL - LL); PhaseList(ref fifoPsn, 20, Psn, out HL, out LL); if( HL - LL > 0.85 ) widthSwg = 0.01; else widthSwg = 0.15 * (HL - LL); psnSer[bar] = 10 * Psn - 5d; // Calculate Trend Vigor this bar // (Filter Bandpass component - same as Swing above; substitute variable names) //Pythagorean theorem to establish cycle amplitude double Ampl2 = Math.Sqrt(BP2 * BP2 + Q2 * Q2); //Trend amplitude taken over the cycle period int cycPeriod = (int)(domCycMdn[bar] - 1); if( cycPeriod < 12 ) cycPeriod = 12; double Trend = ds[bar] - ds[cycPeriod]; if( Trend != 0 && Ampl2 != 0 ) ratio = 0.33 * Trend /Ampl2 + 0.67 * ratio1; if( ratio > 10 ) ratio = 10d; if( ratio < -10 ) ratio = -10d; double tv = 0.05 * (ratio + 10d); if( tv < 0.3 || tv > 0.7 ) widthTV = 0.01; if( tv >= 0.3 && tv < 0.5 ) widthTV = tv - 0.3; if( tv >= 0.5 && tv <= 0.7 ) widthTV = 0.7 - tv; tvSer[bar] = 20d * tv - 10d; /* Plot the rasters... */ int snr50 = (int)Math.Round(50 * snr); int psn50 = (int)Math.Round(50 * Psn); int tv50 = (int)Math.Round(50 * tv); for( int n = 1; n < 51; n++ ) { // 0.4 used below comes from 20/50 to normalize the color from 1 to 20 double raster = 20d; if( n < snr50 ) // bottom of corona raster = 0.5 * (Math.Pow((20 * snr - 0.4 * n) / Width, 0.8) + raster2[n]); else if( n > snr50 && (0.4 * n - 20 * snr) / Width > 1 ) // top of corona raster = 0.5 * (Math.Pow((-20 * snr + 0.4 * n) / Width, 0.8) + raster2[n]); else if( n == snr50 ) raster = 0.5 * raster2[n]; if ( raster > 20 ) raster = 20; else if ( raster < 0 ) raster = 0; if ( snr > 0.5 ) raster = 20; SetSeriesBarColor(bar, Raster[n], colorSNR[(int)(raster)]); raster2[n] = (int)raster; // Plot the Swing raster double rasterSwg = 20d; if( n < psn50 ) // bottom of corona rasterSwg = 0.5 * (Math.Pow((20 * Psn - 0.4 * n) / widthSwg, 0.95) + 0.5 * raster2Swg[n]); else if( n > psn50 && (0.4 * n - 20 * Psn) / widthSwg > 1 ) // top of corona rasterSwg = 0.5 * (Math.Pow((-20 * Psn + 0.4 * n) / widthSwg, 0.95) + 0.5 * raster2Swg[n]); else if( n == psn50 ) rasterSwg = 0.5 * raster2Swg[n]; if ( rasterSwg > 20 ) rasterSwg = 20; else if ( rasterSwg < 0 ) rasterSwg = 0; if ( HL - LL > 0.8 ) rasterSwg = 20; SetSeriesBarColor(bar, RasterSwg[n], colorSwg[(int)(rasterSwg)]); raster2Swg[n] = (int)rasterSwg; // Plot the Trend Vigor raster double rasterTV = 20d; if( n < tv50 ) rasterTV = 0.8 * (Math.Pow((20 * tv - 0.4 * n) / widthTV, 0.85) + 0.2 * raster2TV[n]); else if( n > tv50 ) // top of corona rasterTV = 0.8 * (Math.Pow((-20 * tv + 0.4 * n) / widthTV, 0.85) + 0.2 * raster2TV[n]); else if( n == tv50 ) rasterTV = 0.5 * raster2TV[n]; if( rasterTV < 0 ) rasterTV = 0; if( rasterTV > 20 || tv < 0.3 || tv > 0.7 ) rasterTV = 20; SetSeriesBarColor(bar, RasterTV[n], colorTV[(int)(rasterTV)]); raster2TV[n] = (int)rasterTV; } avg1 = avg; signal1 = signal; noise1 = noise; BP2_2 = BP2_1; BP2_1 = BP2; ratio1 = ratio; } HideVolume(); HidePaneLines(); PlotSeries(dbPane, domCycMdn, Color.Yellow, WealthLab.LineStyle.Solid, 2); DrawLabel(dbPane, "Dominant Cycle|", Color.Black); PlotSeries(snrPane, snrSer, Color.FromArgb(220, 255, 255), LineStyle.Solid, 2); DrawLabel(snrPane, "SNR|", Color.Black); PlotSeries(swgPane, psnSer, Color.FromArgb(180, 255, 210), LineStyle.Solid, 2); DrawLabel(swgPane, "Swing Position|", Color.Black); PlotSeries(tvPane, tvSer, Color.FromArgb(64, 128, 255), LineStyle.Solid, 2); DrawLabel(tvPane, "Trend Vigor|", Color.Black); } protected override void Execute() { // Declare the DataSeries to pass to the method DataSeries dc, snr, swing, tv; // Get the dominant cycle, SNR, Swing Position, and Trend Vigor for use in a strategy SuperIndicators(AveragePrice.Series(Bars), out dc, out snr, out swing, out tv); } }
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by adeelshahzad, Today, 11:49 AM
|
2 responses
3 views
0 likes
|
Last Post
by adeelshahzad
Today, 12:15 PM
|
||
Started by spottysallrite, Today, 11:31 AM
|
1 response
5 views
0 likes
|
Last Post Today, 11:43 AM | ||
Started by johnMoss, 03-04-2024, 01:53 PM
|
2 responses
32 views
0 likes
|
Last Post
by Overnhou
Today, 11:21 AM
|
||
Started by Padan, Today, 02:02 AM
|
5 responses
17 views
0 likes
|
Last Post Today, 11:14 AM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
8 responses
29 views
0 likes
|
Last Post
by Lele2k24
Today, 11:00 AM
|
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment