Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Referencing prior "Swing" Indicator Values
Collapse
X
-
Referencing prior "Swing" Indicator Values
I currently using a moving centerline defined as (high + low)/2 for a specified lookback period to help identify the trend and for entry points, but I think it would work better to use the swing indicator figures for a specified number of prior swing highs and swing lows, e.g. 3, 5, 10 etc. In that manner, the "lookback period" would self adjust separately for highs and lows to the most current swings. Because the number of bars ago that each swing occurred will vary, is there a way to refer to the prior swings other than using a specified number of bars? Thank you.Tags: None
-
Vegasfoster, you could check how many bars ago the swing point occured and then plug this for example in the High / Low indexes to access those swing price values then to compare for the trend structure - http://www.ninjatrader-support.com/H...eV6/Swing.htmlBertrandNinjaTrader Customer Service
-
That's a great start, thank you. I can make it work using the following, but the number of prior swings used in the calculation isn't variable.
Center.Set( (
High[Math.Max(0, Swing(strength).SwingHighBar(0, instances, period))] +
High[Math.Max(0, Swing(strength).SwingHighBar(0, instances - 1, period))] +
High[Math.Max(0, Swing(strength).SwingHighBar(0, instances - 2, period))] +
Low[Math.Max(0, Swing(strength).SwingLowBar(0, instances, period))] +
Low[Math.Max(0, Swing(strength).SwingLowBar(0, instances - 1, period))] +
Low[Math.Max(0, Swing(strength).SwingLowBar(0, instances - 2, period))]
)/6 );
So I am trying the following but it isn't plotting. I tried using Print("AverageHigh") and Print(AverageHigh) but nothing shows in the output window. I am not 100% on how to get data to show in the output window, I added indicator to chart and then recompiled the indicator, but nothing shows, is that the correct way? Not sure how else to troubleshoot. Thanks for any help.
{
if (CurrentBar < period)
{
return;
}
double y = 0;
int number1 = instances;
for (int n1 = 0; n1 < number1; n1++)
{
y = y + (High[Math.Max(0, Swing(strength).SwingHighBar(0, n1, period))]);
}
double AverageHigh = y / instances;
double z = 0;
int number2 = instances;
for (int n2 = 0; n2 < number2; n2++)
{
z = z + (Low[Math.Max(0, Swing(strength).SwingLowBar(0, n2, period))]);
}
double AverageLow = z / instances;
Center.Set( ( (AverageHigh + AverageLow)/2) );Attached FilesLast edited by vegasfoster; 04-07-2010, 03:59 PM.
Comment
-
Ok, it said,
"4/7/2010 1:47:33 PM|3|4|Error on calling the 'OnBarUpdate' method for indicator 'MovingSwingCenter2' on bar 200: Swing.SwingHighBar: instance must be greater/equal 1 but was 0"
So I changed "int number1 = instances;" to "int number1 = instances + 1;" and "for (int n1 = 0; n1 < number1; n1++)" to "for (int n1 = 1; n1 < number1; n1++)" for both the high and low and that fixed the problem. Thanks, learned something new to look at.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tim-c, Today, 03:54 AM
|
0 responses
3 views
0 likes
|
Last Post
by Tim-c
Today, 03:54 AM
|
||
Started by FrancisMorro, Today, 03:24 AM
|
0 responses
2 views
0 likes
|
Last Post
by FrancisMorro
Today, 03:24 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
10 responses
1,771 views
0 likes
|
Last Post
by Leafcutter
Today, 03:01 AM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, 04-23-2024, 07:51 PM
|
2 responses
31 views
0 likes
|
Last Post
by Max238
Today, 02:25 AM
|
||
Started by Shansen, 08-30-2019, 10:18 PM
|
24 responses
945 views
0 likes
|
Last Post
by spwizard
Today, 01:29 AM
|
Comment