Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 05-11-2012, 04:52 PM   #1
DharmaTrader
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks: 3
Thanked 0 times in 0 posts
Default NT7 Swing Indicator Returning Different Values with COBC=false

Hi,

I'm working on an indicator that uses the built-in NT7 Swing indicator to tell my code what the latest Swing High/Low is. When I run my indicator with the COBC=true, it is reporting the correct values (The high/low of the swing point). When I run my indicator with COBC=false, it reports different values (The open/close of the bar following the swing point). This doesn't make any sense to me as the Swing indicator should just return the Swing High/Low dataseries. Why would the setting of the COBC value modify the Swing values being reported?

Any help figuring this out will be much appreciated.

I've included 2 text files (one file for each COBC setting) containing the Swing high/low output for the time period in the image between the 2 vertical blue bars.

Here is the simplified code which will reproduce what I'm seeing:
public class DTSwingTest : Indicator
{
#region Variables

private int swingStrength = 6;

private double swingLow = 0;

private double swingHigh = 0;

// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{

// Setting Overlay to true means our indicator will be defaulted to plot on the price panel
Overlay = true;

// Set to false so that tests of the swing points can alert immediately
CalculateOnBarClose = false;


}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

if(Historical)
return;

if (FirstTickOfBar)
{

swingLow = Swing(swingStrength).SwingLow[0];
swingHigh = Swing(swingStrength).SwingHigh[0];

Print ( Time[0].ToString() );
Print ( Instrument.MasterInstrument.Name + " Swing Low : " + swingLow );
Print ( Instrument.MasterInstrument.Name + " Swing High : " + swingHigh );
}



}

#region Properties

#endregion
}

}
COBCTrueSwings.txt

COBCFalseSwings.txt

Swing.jpg
DharmaTrader is offline  
Reply With Quote
Old 05-12-2012, 12:44 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 388 times in 376 posts
Default

Dharma,

The swing indicator essentially goes back and sets values as new information comes in and as such this may explain your issue. In addition, calculate on bar close set to false allows the indicator to update via the most recent bar, whereas calculate on bar close set to true has the indicator only calculate when a bar closes.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 05-15-2012, 12:04 PM   #3
DharmaTrader
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks: 3
Thanked 0 times in 0 posts
Default

Adam,

I understand that the COBC=false would allow the swing indicator to look at the intrabar data of the current bar but with a swing strength setting of 6, the current bar wouldn't be eligible as a swing point until another 5 bars had closed and shouldn't even be factored in to calculating the last swing point except for marking the last swing point as invalid if the high/low of that bar had been surpassed by the current bar.

Also, per my attached info, the Swing indicator is reporting the open/close value instead of the high/low when the COBC=false. Isn't the Swing designed to report the high/low values of the bars that become swing points? It doesn't make sense to me that it would ever report a value other than a high/low regardless of the COBC setting.

What do you think?

-Thanks
DharmaTrader is offline  
Reply With Quote
Old 05-15-2012, 01:03 PM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 388 times in 376 posts
Default

Dharma,

It looks like this thread may have covered something similar before : http://www.ninjatrader.com/support/f...ad.php?t=48386

The Swing indicator can be challenging to work with, I suggest you just plot the High / Low values programmatically accessed to see what info is available as the 'visual only' one you used on the chart is backfitting it's results to easily show the current swing structure of the market analyzed.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 05-24-2012, 07:35 PM   #5
DharmaTrader
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks: 3
Thanked 0 times in 0 posts
Default

Adam,

Thanks. I was able to get my indicator working using the information from the link that you provided.
DharmaTrader is offline  
Reply With Quote
Old 05-15-2018, 05:15 PM   #6
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 290
Thanks: 13
Thanked 7 times in 7 posts
Default Even in NT8, Swing indicator still broken without Calculate.OnBarClose

Hi,
in NT7 it has been known for years now that the Swing indicator does not work without CalculateOnBarClose true.
In NT8, one would hope for an improvement, but no, it is still the same flaw.
Yes, there is advice for a workaround, but why not just provide a Swing indicator that works properly?

saltminer
saltminer is offline  
Reply With Quote
Old 05-16-2018, 02:07 PM   #7
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,496
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello saltminer,

Thank you for your post.

Attached are two indicators (one for NT7 and one for NT8) that pull the Swing High and Low in realtime with the correct Swing High and Low values.

These indicators use a Strength of 5 and should be applied to your chart that is using the Swing indicator with a Strength of 5 while the Output window is open.

Please let me know how you are varying from these indicators and what values you are trying to pull that are not appearing in realtime.
Attached Files
File Type: zip TestRealtimeSwingNT8.zip (4.3 KB, 3 views)
File Type: zip TestRealtimeSwingNT7.zip (4.5 KB, 4 views)
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 05-17-2018, 05:00 PM   #8
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 290
Thanks: 13
Thanked 7 times in 7 posts
Default

Hi,
thanks for those, but there is an even clearer way to see the problem. Just use AddChartIndicator(Swing(5)) within a strategy that is calculating tick by tick.

See attached screenshot. The realtime bars at right are producing incorrect swings, while the historical ones at left are ok.

saltminer
Attached Images
File Type: png swing capture.PNG (16.0 KB, 14 views)
saltminer is offline  
Reply With Quote
Old 05-18-2018, 08:55 AM   #9
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,496
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello saltminer,

Thank you for your response.

I cannot reproduce that behavior on my end with the attached script. Can you detail if your script varies from mine and if so please detail the differences?

I look forward to your response.
Attached Files
File Type: cs TestSwingInRealtimeStrategy.cs (2.2 KB, 2 views)
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 05-22-2018, 09:14 PM   #10
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 290
Thanks: 13
Thanked 7 times in 7 posts
Default

Hi,
I don't think you waited long enough. Your script does indeed misbehave. See attached screenshot. This is on 5 range chart. Blue line is transition from historical to realtime.

saltminer
Attached Images
File Type: png swing bad behaviour.PNG (50.1 KB, 15 views)
saltminer is offline  
Reply With Quote
Old 05-23-2018, 12:43 PM   #11
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,496
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello saltminer,

Thank you for your response.

You are correct. I will follow up here when I have details on this matter.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 05-27-2018, 12:44 PM   #12
eddi0505
Junior Member
 
Join Date: Aug 2014
Posts: 21
Thanks: 0
Thanked 1 time in 1 post
Default

HI PatrickH,

any update on that? Would be great if we could use this indicator in real time with correct values in our strategies...
eddi0505 is offline  
Reply With Quote
Old 05-29-2018, 07:12 AM   #13
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,496
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello eddi0505,

Thank you for your note.

I do not have an update on this but I will update this thread when I do.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 06-01-2018, 11:19 AM   #14
eddi0505
Junior Member
 
Join Date: Aug 2014
Posts: 21
Thanks: 0
Thanked 1 time in 1 post
Default

Hello. On a lot of threads I read
"
Yes, I was able to see the error but at this point have no further details I can relay. Once I have more details on this request I will reply back here.
"

from a NT representative.

Therefore, as it seems that such replies have taken system, can you please tell us what your expectations are for a usable Swing-Indicator as per below asked by DharmaTrader. When do you think you can make this available?
eddi0505 is offline  
Reply With Quote
Old 06-01-2018, 01:30 PM   #15
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,496
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello eddi0505,

Thank you for your post.

The Swing is working as needed on Historical data and when using the options to calculate on the close of the bar.

We are working on correcting the behavior for real-time processing (when not calculating on the close of the bar) and I have every intention of keeping this thread up to date.
NinjaTrader_PatrickH is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting an indicator to COBC = false from a strategy dpicon Platform Technical Support 11 05-28-2012 05:35 AM
SMA indicator returning odd values... DrkShadow General Development 7 05-04-2012 11:22 PM
COBC = false and stops jrtrader Platform Technical Support 1 12-03-2010 09:43 AM
Custom indicator not returning correct values annettes Indicator Development 3 09-22-2009 06:16 AM


All times are GMT -6. The time now is 07:04 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 ones 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.