View Full Version : Automatic Trend Line Detection and Alert
NinjaTrader_Ray
08-26-2007, 10:05 AM
This is an indicator I published for the September 07 issue of S&C. This indicator is provided on an "as-is" basis.
To import:
- Download the file contained in this thread to your desktop
- From the Control Center window select the menu File > Utilities > Import NinjaScript
- Select the downloaded file
BC5391
08-27-2007, 09:55 PM
Thanks Ray,
I did modify the alert, any wave file you want can be created here
http://public.research.att.com/~ttsweb/tts/demo.php
prostyle
09-19-2007, 11:57 AM
Hello,
You auto trend line is GREAT! I love it.
Have a question for you. How hard would it be
to devise a indicator that works the same type of
way but works with divergence?
Ie - plots the divergence between price action
and say macd or stoch or both :-)
Thanks,
Colin
RK_trader
09-21-2007, 01:29 AM
Thanks Ray for the auto trendline indicator.
When I tried to install it is trying to overwrite the default "swing"indicator, is this expected? Does it change swing indicator in anyway?
What does the "strength" field indicate? Does it indicate number of swing pivots needed for drawing the trendline?
Did you test whats the optimum strength field for ES 3 min chart. Appreciate your time on this.
Thanks
RK
NinjaTrader_Josh
09-21-2007, 02:29 AM
The reason it is trying to overwrite the Swing indicator is because the way the export NinjaScript is designed is to allow the export file to work on its own. You can safely overwrite your Swing indicator as it is the same file. There will be no changes done.
NinjaTrader_Ray
09-21-2007, 07:59 AM
Strength represents the number of bars left and right of a pivot required to form a pivot. I have not done any optimization to determine best values on any time frame.
RK_trader
09-21-2007, 08:08 AM
Thanks Josh. I appreciate it.
Do you know what the "strength" field indicates? Does it indicate number of swing pivots needed for drawing the trendline?
Did you test whats the optimum strength field for ES 3 min chart. Appreciate your time on this.
Thanks
RK
RK_trader
10-01-2007, 12:14 AM
Hi
Any active users of this auto trendline indicator, did you experiment with what "strength" property value you are getting good results? I tried 5 and not sure if it is good.
Also when does it give the signal. Does it wait for atleast one bar to close below the current trendline?
Josh thanks for good indicator. I am not a Ninja programming expert, trying to learn the indicator programming. Is it possible you can modify the indicator to include a property field "the number of bars to close below trendline to give signal"
Also I would like to request if you are considering enhancements to make the trendline a little below the swing lows with a "displacement". For example in an uptrend the trendline is joining the swing low pivots. I am finding that if the trendline is a bit conservative and like a few ticks below the swing lows, it is holding well. For example, if the swing lows in ES uptrend are like 1531.50, 1535.50, 1540.50, then a line joining 1531.25 ,1535.25,1540.25 with 0.25 displacement to downside is holding really well and when it breaks, it gives a very strong signal and doesn't give false signals. May be this can be enhanced by adding a "displacement field" to properties.
I appreciate your time and any active users opinion on this.
Thanks
RK
NinjaTrader_Josh
10-01-2007, 12:20 AM
Unfortunately I cannot provide assistance on this indicator RK_trader. It wasn't me who programmed this one and so I do not know what the parameters do or mean.
RK_trader
10-01-2007, 12:46 AM
Thanks Josh for the quick reply. No problem.
I would appreciate opinions/comments on people who are actively using this indicator. Any volunteers who can modify the code to get the enhancements/options.
Thanks
RK
NinjaTrader_Ray
10-01-2007, 03:33 PM
The indicator waits for the first value lower or higher than a uptrend or downtrend line. If the indicator's "Calculate on bar close" is set to true, it will wait for a close of the bar otherwise just the first tick.
Unfortunately I will not be ammending the code to provide extra user defineable parameters however, anyone can take this open source code and modify it as they wish.
RK_trader
10-01-2007, 10:24 PM
Thanks Ray. I am still in learning phase of Ninja programming.
I see "calculateonbarclose" on line 42 in Initialize() and it is set to true
And the other place I see it is on line 298 which says as below:
indicator.CalculateOnBarClose = CalculateOnBarClose;
Can you please clarify as to in which line, I need to change the value to true, so that it waits for a a bar to close below the trendline to give the alert.
Appreciate your time on this.
Thanks
RK
NinjaTrader_Ray
10-02-2007, 08:53 AM
Line 42 should be set to 'true'.
RK_trader
10-02-2007, 10:59 AM
Hi Ray,
In line 42, it is already set to true.
Thanks
RK
APat1
10-17-2007, 09:03 AM
If it is set tof alse the calcs are on incoming tick basis.
Probably can change it in the indicator prop window.
Pat
RK_trader
10-17-2007, 11:57 PM
Hi Apat1,
It is set to true in the code and also in the properties window by default. But I see it gives signal even before a bar closes below the trend line. Not sure what to change to fix it, so that it gives signal only when a bar "closes" below trendline.
Thanks
RK
Mike_32
05-07-2008, 09:15 AM
Does anyone understand the methodology of using this indicator?
When it gives a long trendline are you supposed to go long?
Or wait until it goes long and gives the arrow of breaking the trend then go short?
What is the arrow breaking the trendline supposed to signify exit the line trend or go other direction?
Thanks
NinjaTrader_Ray
05-07-2008, 10:02 AM
There is no trading methodology on this indicator. Its purely a visual that draws trendlines and alerts you to a break. Interpret as you see fit.
superarrow
11-26-2008, 11:35 PM
Hi Ray,
Firstly, thanks to the best indicator I ever used. It makes my trading so much easier.
Now, I need to visually analyze the price for the whole day, not just during an active trendline drawn object. I tried to comment out all the "RemoveObject..." to try and keep all the arrows for the previous trendline breaks. However, this does not seem to work.
Would you be able to advice/guide me to make this feature possible? Appreciate your assistance.
Happy Thanksgiving to you and the entire NT team. You guys do a great job.
Cheers,
SA
NinjaTrader_Ray
11-27-2008, 08:18 AM
You are welcome...Not looking at the code, I suspect in the DrawArrow() call, the same tag parameter is used for each break, try changing this to be unique such as:
DrawArrow(CurrentBar.ToString()...)
superarrow
11-30-2008, 07:01 AM
Ray,
Thank you. Works!
SA
pgabriel
01-12-2009, 11:54 AM
Is it possible to modify this indicator to leave a history of the prior trend lines on the chart when a new one is plotted...?
NinjaTrader_Bertrand
01-12-2009, 12:12 PM
Hi pgabriel, you could apply the same concept as discussed for the plotting the past break points (unique tag ID's) to the DrawRay() statements by adding + CurrentBar to them...this would then create a new draw object each time leaving the history of objects unmodified.
goldfly
01-12-2009, 12:31 PM
Here
http://www.ninjatrader-support2.com/vb/showthread.php?t=6648
Get "TrendlinesAll.zip (http://www.ninjatrader-support2.com/vb/attachment.php?attachmentid=2217&d=1208053993)"
Edit: I'm not sure how I did that, but you can just click TrendlinesAll in this message.......
pgabriel
01-12-2009, 01:23 PM
Thanks... that was quick...but as the lines are all rays it really clutters up the chart...can you limit the history to just the current day...?
diage4
01-14-2009, 03:48 PM
Some trendline softwares have delete old trendlines functions.
I noticed that there are so many great trendlines for Metatrader, but unfortunately this is very different story for Ninjatrader.
Is it because Ninjatrader is difficult to program trendlines? Or is it because people who are not interested in developing indicators for Ninjatrader?
dannyss35
04-21-2009, 05:07 PM
well I downloaded the file and saved it on my desktop. I have to copy and paste however I do not remember how...anyone can help me?
NinjaTrader_Bertrand
04-22-2009, 03:06 AM
Welcome to our support forums dannyss35 - just go to File > Utilities > Import NinjaScript and point to the downloaded zip file then.
timokrates
04-27-2009, 11:45 AM
Hi,
first, thanks for this tool.
One question: Could it be modified to also draw the contrary trendline to create a channel?
NinjaTrader_Bertrand
04-27-2009, 11:50 AM
Hi timokrates, this would be possible - you can review the sourcecode of this study and work the needed changes in. If you need the modification professionally programmed, please consider contacting those consultants - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
jaybird151
04-30-2009, 09:57 AM
is there anyway that you can make this draw the up trendline and down trend line at the same time instead of it just plotting 1 or the other
thanks
NinjaTrader_Bertrand
04-30-2009, 10:01 AM
Hi jaybird151, this should be possible, but unfortunately we don't offer custom code modifications. You could contact a NinjaScript consultant for this project - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
ZMaxx
05-20-2009, 03:18 PM
hello,
thank you for this great indicator. I would like to ask if it can be modified to keep all trend lines, not they disappear.
It is ilustrated on attached picture.
thanks for your help.
Zmaxx
ZMaxx
05-21-2009, 01:35 PM
Hello,
is there anyone who can help me? I have tried to modify Auto Trend Line indicator, but there is no result. I need to keep the automatic lines in the chart. Is there any possibility to do that?
thank you for your help.
ZMaxx
nkhoi
05-21-2009, 02:03 PM
Hello,
is there anyone who can help me? I have tried to modify Auto Trend Line indicator, but there is no result. I need to keep the automatic lines in the chart. Is there any possibility to do that?
thank you for your help.
ZMaxx
http://www.tradingstudies.com/
go to download section , look for the tape indicator, it draws channel without deleting old t/l.
superarrow
05-21-2009, 11:11 PM
ZMaxx,
See post #20:
You are welcome...Not looking at the code, I suspect in the DrawArrow() call, the same tag parameter is used for each break, try changing this to be unique such as:
DrawArrow(CurrentBar.ToString()...)
ZMaxx
05-25-2009, 03:18 PM
To Superarrow:
Thanks but I can not understand it too much. Can you tell me what did you do to works that? I am not so good in to modify some codes.
thanks for your help.
ZMaxx
toddaclark
05-28-2009, 03:22 PM
I use this AutoTrend Line indicator and like it a lot.
I'm trying to figure out how to keep the arrows from disappearing when a new trend line is drawn. I would like to be able to look back thru the whole day on my 233 tick chart of ES and see what trendlines broke.
Can someone help find where to change the code to make that happen?
Thanks,
TC
NinjaTrader_Josh
05-28-2009, 04:20 PM
You will likely need to examine the code and submit with unique names for each drawing object so it does not overwrite the old one.
toddaclark
05-28-2009, 04:33 PM
Josh,
Thanks for your reply. I've attached the indicator.
I've looked at the code but don't see where I should submit unique names for the arrows. I'm not sure what to do.
Would it be possible for you to open the code, make the change and re-attach the revised code?
TC
NinjaTrader_Josh
05-28-2009, 04:49 PM
Look at all the areas that have DrawRay or DrawArrowDown. They all have non-unique string names. Give them unique string names if you do not want them to overwrite each other.
Bear in mind you need to then mess around with the RemoveDrawObject() lines. Unfortunately those are the only pointers I can give you to get you in the right direction. I cannot amend the indicator for you at this point in time.
designer
06-07-2009, 11:31 PM
Creating a strategy with AutoTrendlines....In the Strategy Wizzard I am trying to create a strategy where i enter a position when price close crosses above the trendline...but for some reason does not seem to be triggering the orders when the strategy is added to the chart. Am i doing something wrong? Please see screenshot attached.
Thanks
NinjaTrader_Bertrand
06-08-2009, 05:06 AM
designer, this is expected since the plotted trendlines can't be used directly in the wizard to generate auto trades. For this you unfortunately need advanced custom code giving your the exact trend line values to trigger trades from.
trader1512
06-17-2009, 08:00 PM
has anyone modified the code to keep the trend lines and arrows on the chart after trend ends?
designer
06-17-2009, 10:09 PM
Not that am aware of...
mat j
07-28-2009, 10:11 PM
This is an indicator I published for the September 07 issue of S&C. This indicator is provided on an "as-is" basis.
To import:
- Download the file contained in this thread to your desktop
- From the Control Center window select the menu File > Utilities > Import NinjaScript
- Select the downloaded file
Hi there,
Can somebody help me on converting CS File to Mq4. I've downloaded it but still no avail in using it.
Thanks & cheers.
NinjaTrader_Bertrand
07-29-2009, 05:02 AM
mat j, welcome to our forums! Unfortuantely we can't assist you on converting your NinjaScript files to MQ4.
winja
08-06-2009, 12:42 PM
I tried to import the AutoTrendLine.zip from post #1 but get an error message -
Import Failed. There are NinjaScript files in the imported NinjaScript Archive File that hav programming errors. These errors must be resolved before you can import the NinjaScript Archive File.
Any suggestions? Thanks
winja
nkhoi
08-06-2009, 12:55 PM
you need to go to your indicator folder, move the most recent indicator to somewhere else, also delete user define file, try compiling again, keep doing that until you are able to compile then you know which indicator gives you the trouble.
Mike12345
03-02-2010, 12:04 PM
any one be able to import auto trendline file into NT7 Beta??
Thanks
Mike
NinjaTrader_Bertrand
03-02-2010, 12:07 PM
Please try this one shared here (http://www.ninjatrader-support2.com/vb/showthread.php?t=26327).
Mike12345
03-02-2010, 12:47 PM
Bertrand
Thank you verymuch for your fast respond
I imported and work fine
Thank you again
Mike
designer
03-02-2010, 06:49 PM
Mike, I believe some people can and are indeed able to import auto trendline file into NT7 Beta....at least that is my understanding...
Mike12345
03-04-2010, 11:46 AM
Hi Bertrand
Regarding this code, What I have to do to unlock the trend line just in case. I try to move it and give me a red lock sign, I try to save it as unlock but it is going back next tick to be locked.
Thanks
Mike
NinjaTrader_Bertrand
03-04-2010, 11:50 AM
Try adding this below to Initialize() -
AllowRemovalOfDrawObjects = true;
Mike12345
06-21-2010, 10:28 AM
Thanks Bertrand
I try this and it is not working on calculate on bar close false or true.
just I want be able to move the TL in Auto Trendline indicator by the mouse.
Thanks
Mike
NinjaTrader_Bertrand
06-21-2010, 11:27 AM
Sorry Mike, to unlock the drawn objects, you can set locked to false programmatically with this snippet here in the OnBarUpdate() code portion - http://www.ninjatrader.com/support/helpGuides/nt7/idrawobject.htm
Mike12345
06-21-2010, 11:48 AM
Thanks Bertrand
I did that and I have been able to move the past TL not the current one??
Thanks Again
Mike
NinjaTrader_Bertrand
06-21-2010, 12:13 PM
Sorry don't follow you, if I apply this on the code I referenced on # 51 I see one current ray drawn and it's unlocked i.e. freely movable then after this snippet is added.
Mike12345
06-21-2010, 12:52 PM
Thanks Bertrand
Yes I add on # 51.
I attach a copy of the code, I may missing something, thanks for help me.
if you don't mind would you please check it.
Thanks
Mike
Sorry it deosn't let me attach the full code here but if I get you email I will email it to you
///<summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///</summary>
protectedoverridevoid Initialize()
{
DisplayInDataBox = false;
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Loops through the DrawObjects collection
foreach (IDrawObject draw in DrawObjects)
{
// Unlocks all draw objects for manual manipulation on the chart
draw.Locked = false;
}
// Calculate up trend line
int upTrendStartBarsAgo = 0;
int upTrendEndBarsAgo = 0;
int upTrendOccurence = 1;
while (Low[upTrendEndBarsAgo] <= Low[upTrendStartBarsAgo])
Mike12345
06-21-2010, 01:07 PM
This a little video explain what happend
Thanks
http://www.screencast.com/users/MikeFuturetrader/folders/Jing/media/e2dd1888-d66d-44fb-a5ac-256322c25188
NinjaTrader_Josh
06-21-2010, 03:44 PM
Mike,
In your code you will need to set the lock property for the object to false.
Please see the example here: http://www.ninjatrader.com/support/helpGuides/nt7/idrawobject.htm
Mike12345
06-21-2010, 05:36 PM
Thanks Bertrand
I view the code again but I didn't find anything related to unlock, Do I missing anything.
Thanks
Mike
NinjaTrader_Austin
06-21-2010, 05:46 PM
Mike, if you are using CalculateOnBarClose = true, you will have to wait until the most current bar is completed (or for a new bar to start, it is the same event) before the current trend line will be unlocked.
If CalculateOnBarClose is set to false, you will just have to wait for the next tick to come in before the trend line will be unlocked.
Mike12345
06-21-2010, 06:59 PM
Thanks Bertrand
I have CalculateOnBarClose is set to false, and I wait a 2 or 3 tick and after that one TL is moving and the current one is locked.
is any way to load the code or send it for you.
I run NT 7/17
Thanks for helping
Mike
NinjaTrader_Bertrand
06-22-2010, 04:25 AM
Hi Mike, you can send the code you use to support at ninjatrader dot com to my Attn, so I can take a look - thanks.
Mike12345
06-22-2010, 04:56 AM
Thanks Bertrand
I will do so
Thanks for help
Mike
dsraider
07-09-2010, 10:03 AM
Has anyone been able to use this awesome indicator on something other than price, i.e. Stochs PeriodK or something like that? It could make for a mean divergence indicator.
RitaPacheco
07-12-2010, 12:17 PM
Hi
Since last week I can not see the lines of this indicator only the Arrows.
I already reimported the indicator from the forum and imported again into the NT but didn't fix it.
I have NT 6,5.1000.16
Do you know how fix this?
Thanks
NinjaTrader_Bertrand
07-12-2010, 12:43 PM
Rita, any errors in the log tab of your Control Center as this happens?
RitaPacheco
07-12-2010, 12:49 PM
No errors on the log tab of myControl Center
I can see arrows but not lines