![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Time for my daily post on here.....
I have a problem where it seems a signal is being triggered early in a session by reference to the swing high or low of a previous session if one hasn't formed yet during this session. Does anyone have any ideas how I can address this? Thanks Mark |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Mark,
Using Swing as a condition for entry will generally be challenging for this reason. When you're looking at historical swing values, these are actually generated by future values, causing a discrepancy with what you see on the chart compared to what is available programatically. You may get better results basing trade conditions on indicators that only have a historical lookback, rather than repainting ones like swing.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Hi Ryan
I have not explained it clearly enough. I'm not using the swing indicator for entry it is used for exit. What is happening however is when a trade is entered into (short for example), if the price is higher than the last swing high (which was last session) it sends a signal to exit the trade. As it happens the exact same time as the entry, the trade does not exit but i'm just concerned that in theory it could. Is there anyway round this? |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
|
Mark, I believe you could use the High and Low bar methods of the Swing indicator here as workaround to check to how long back this Swing point was found and then not submit the exit if it's one from the prior day / session.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Could you write a brief example please Bertard?
Many thanks Mark |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
|
I would unfortunately not have a code snippet handy, but the methods you would need to work with are shown here - http://www.ninjatrader.com/support/h.../nt7/swing.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
I'm still having problems with this unfortunately.
![]() I entered into a trade yesterday. At 99.40 on the CL contract. A swing low exit was triggered straight away despite the swing low being aproximately $1 below. The output log is as follows: Quote:
Code:
if (GetCurrentAsk() < Swing(5).SwingLow[0] - (OffsetS * TickSize)
&& Avalue == 1)
{
ExitLong();
Print("Exit Long Swing Low exit");
}
Thanks Mark
|
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Can anyone help with this please?
|
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Whether you're using swing as conditions for entry or exit is pretty much the same. The value accessed programatically varies from what you see visually, as discussed earlier. You should generally not use swing in automated strategies.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#10 | |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
Using the swing indicator is a key part of my strategy. Without it, I don;t have a strategy and therefore the need to continue paying your subscription. It works fine when back tested (irrespective of if it differs from the charts). I need to know how it is working during live trading and therefore need to print the SwingLow and SwingHigh values to the output window. To see what is going on. How can I do this at regular intervals say on the start of a new bar. (bear in mind I have the strategy set up as CalculateOnBarClose = False) Many thanks Mark |
|
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
You can Print the current value of Swing highs and lows. If you want to check on the start of a bar you can use FirstTickOfBar when using COBC = false.
http://www.ninjatrader.com/support/h...ttickofbar.htm if (FirstTickOfBar) Print(Swing(3).SwingHigh[0]); When you look at the same bar historically it will not necessarily be the same value. This indicator works great when you backtest because it has a forward bias.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#12 | |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
Strangly it has worked fine today when traded using the sim account. |
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
Ryan - problem identified straight away!
According to the chart - the first SwingHigh of the session occured at 14.27 (GMT) at a high of $100.04. the first SwingLow at 14.02 (GMT) at $99.02. These values are still showing up in the following (at 19.00 GMT): Code:
Print(Swing(10).SwingHigh[0]); and Print(Swing(10).SwingLow[0]); Thanks |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
The values has just changed @ 19.22 (GMT) to the second SwingHigh/Low which occured about 15.00 (GMT).
|
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
|
According to the chart there about 8 Swing Highs and Lows after this...
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Swing High / Low Indicator | lawyse | Indicator Development | 1 | 12-03-2009 11:33 AM |
| Modify Swing High/Low Indicator | yimbot | Indicator Development | 5 | 12-30-2008 06:16 AM |
| How to use Swing(High/Low) indicator | cassb | Strategy Analyzer | 5 | 03-05-2008 10:56 PM |
| Swing high low indicator | winJR | NinjaScript File Sharing Discussion | 1 | 02-06-2008 12:39 AM |
| Swing Low/High indicator | ts888 | Indicator Development | 10 | 07-12-2007 07:56 AM |