NexusFi: Find Your Edge


Home Menu

 





Better Sine Wave or Hilbert Sine wave with S/R lines (Ninjatrader 8)


Discussion in Traders Hideout

Updated
    1. trending_up 250 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Better Sine Wave or Hilbert Sine wave with S/R lines (Ninjatrader 8)

  #1 (permalink)
 rx13 
Delhi, India
 
Experience: Intermediate
Platform: NinjaTrader, others
Trading: Future and Options
Frequency: Every few days
Duration: Days
Posts: 9 since Mar 2023
Thanks Given: 11
Thanks Received: 2

Can someone please tell me if there is a Better Sine wave indicator or Hilbert Sine wave (with S/R lines) available for NT8 in nexusfi (like eminiwatch) ? The only sine wave I find was built for NT7. Here is one from ninjatrader forum but unfortunately it is also made with older version.

https://forum.ninjatrader.com/forum/ninjascript-file-sharing/ninjascript-file-sharing-discussion/16601-ehlers-sine-wave?p=235381#post235381

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #2 (permalink)
 JBWTrader 
Murrays Bay
 
Experience: Advanced
Platform: NT*,Tradestation
Trading: ES, NQ
Frequency: Many times daily
Duration: Seconds
Posts: 77 since Aug 2017
Thanks Given: 3,846
Thanks Received: 104

i put into chat gpt 4.0 and it spat out this

using System;
using NinjaTrader.Cbi;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.Strategies;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript.StrategyAnalyzer;
using NinjaTrader.Gui.StrategyAnalyzer;
using NinjaTrader.NinjaScript.Strategies.SpreadAnalyzer;
using NinjaTrader.NinjaScript.StrategyAnalyzerMetrics;

namespace NinjaTrader.NinjaScript.Strategies
{
public class TrueHilbertSineWaveIndicator : Strategy
{
private int period;
private double[] price;
private double[] hilbert;
private double[] sine;
private double[] leadSine;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"True Hilbert Sine Wave Indicator";
Name = "TrueHilbertSineWaveIndicator";
Calculate = Calculate.OnEachTick;
IsOverlay = true;

// Default period for the Hilbert Transform
period = 40; // This value can be adjusted based on the frequency of the cycle
price = new double[period];
hilbert = new double[period];
sine = new double[period];
leadSine = new double[period];
}
}

protected override void OnBarUpdate()
{
if (CurrentBar < period)
return;

// Store the median price in the price array
price[0] = (High[0] + Low[0]) / 2;

// Compute the Hilbert Transform
for (int i = 0; i < period; i++)
{
double sum = 0.0;
for (int j = 0; j < period; j++)
{
if (i - j >= 0)
{
sum += price[j] * Math.Sin(Math.PI * (i - j) / period);
}
}
hilbert[i] = sum;
}

// Compute the Sine and Lead Sine
for (int i = 0; i < period; i++)
{
sine[i] = Math.Sin(Math.Atan2(hilbert[i], price[i]));
if (i > 0)
{
leadSine[i] = sine[i - 1];
}
}

// Plot the Sine and Lead Sine values
Values[0][0] = sine[0];
Values[1][0] = leadSine[0];
}

public override string[] DataSeries
{
get { return new string[] { "Sine", "Lead Sine" }; }
}
}
}


Key Points:
Complexity: This implementation is more complex and attempts to more accurately represent the Hilbert Transform. It calculates a continuous sine wave representation of the price action, useful for identifying market cycles.

Testing and Optimization: This indicator should be thoroughly tested and possibly optimized for the specific asset and time frame you are trading.

Expertise in Signal Processing: The Hilbert Transform is a complex topic in digital signal processing. If you are not familiar with these concepts, you might need further research or consultation with a specialist.

Indicator Characteristics: The Hilbert Sine Wave indicator is used to identify market cycles and should not be used in isolation. It's typically more effective when combined with other indicators and analysis techniques.

Remember to test this script thoroughly in a simulated environment before applying it to live trading, as it's a complex tool and can have significant implications on trading decisions.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 Arthurtrades 
Paris France
 
Experience: Intermediate
Platform: sd
Trading: sd
Posts: 18 since Aug 2023
Thanks Given: 45
Thanks Received: 10



JBWTrader View Post
i put into chat gpt 4.0 and it spat out this



using System;

using NinjaTrader.Cbi;

using NinjaTrader.Gui.Tools;

using NinjaTrader.NinjaScript;

using NinjaTrader.NinjaScript.Strategies;

using NinjaTrader.Data;

using NinjaTrader.NinjaScript.StrategyAnalyzer;

using NinjaTrader.Gui.StrategyAnalyzer;

using NinjaTrader.NinjaScript.Strategies.SpreadAnalyzer;

using NinjaTrader.NinjaScript.StrategyAnalyzerMetrics;



namespace NinjaTrader.NinjaScript.Strategies

{

public class TrueHilbertSineWaveIndicator : Strategy

{

private int period;

private double[] price;

private double[] hilbert;

private double[] sine;

private double[] leadSine;



protected override void OnStateChange()

{

if (State == State.SetDefaults)

{

Description = @"True Hilbert Sine Wave Indicator";

Name = "TrueHilbertSineWaveIndicator";

Calculate = Calculate.OnEachTick;

IsOverlay = true;



// Default period for the Hilbert Transform

period = 40; // This value can be adjusted based on the frequency of the cycle

price = new double[period];

hilbert = new double[period];

sine = new double[period];

leadSine = new double[period];

}

}



protected override void OnBarUpdate()

{

if (CurrentBar < period)

return;



// Store the median price in the price array

price[0] = (High[0] + Low[0]) / 2;



// Compute the Hilbert Transform

for (int i = 0; i < period; i++)

{

double sum = 0.0;

for (int j = 0; j < period; j++)

{

if (i - j >= 0)

{

sum += price[j] * Math.Sin(Math.PI * (i - j) / period);

}

}

hilbert[i] = sum;

}



// Compute the Sine and Lead Sine

for (int i = 0; i < period; i++)

{

sine[i] = Math.Sin(Math.Atan2(hilbert[i], price[i]));

if (i > 0)

{

leadSine[i] = sine[i - 1];

}

}



// Plot the Sine and Lead Sine values

Values[0][0] = sine[0];

Values[1][0] = leadSine[0];

}



public override string[] DataSeries

{

get { return new string[] { "Sine", "Lead Sine" }; }

}

}

}





Key Points:

Complexity: This implementation is more complex and attempts to more accurately represent the Hilbert Transform. It calculates a continuous sine wave representation of the price action, useful for identifying market cycles.



Testing and Optimization: This indicator should be thoroughly tested and possibly optimized for the specific asset and time frame you are trading.



Expertise in Signal Processing: The Hilbert Transform is a complex topic in digital signal processing. If you are not familiar with these concepts, you might need further research or consultation with a specialist.



Indicator Characteristics: The Hilbert Sine Wave indicator is used to identify market cycles and should not be used in isolation. It's typically more effective when combined with other indicators and analysis techniques.



Remember to test this script thoroughly in a simulated environment before applying it to live trading, as it's a complex tool and can have significant implications on trading decisions.

Up

Sent using the NexusFi mobile app

Reply With Quote




Last Updated on December 26, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts