View Full Version : Using drawing tool as input for indicator
traderT
12-04-2008, 04:05 AM
Is it possible to add a line (F2) and pull the start and end value into an indicator?
NinjaTrader_Josh
12-04-2008, 07:28 AM
Unfortunately this is not supported.
traderT
12-04-2008, 07:42 AM
Thanks for the reply. Will this be supported in the future?
Currently I have an indicator that I have written that has two inputs, a high of your choice and a low of your choice. My problem is that I would like to know what bar the 2 inputs come from. Is there an onclick scenario/solution that could be used? Or do you have any other ideas?
NinjaTrader_Josh
12-04-2008, 07:45 AM
It can be done in C#, but is beyond the level of support we can offer. This is on our list of future considerations.
traderT
12-04-2008, 10:37 AM
Is there another way to plot something x bars from the begining of the chart, rather than "bars ago"?
Can a variable be used within a Close, Open, Low, High command. For example ...
private int xbars = 250;
xbars = (CurrentBar - xbarsInput)
Plot1.Set(Close[xbars])
NinjaTrader_Josh
12-04-2008, 10:46 AM
Not sure what you mean. Most [] indexing is on barsAgo. There is no other way. If you wanted the bar at a specific time you want to use GetBar() http://www.ninjatrader-support.com/HelpGuideV6/GetBar.html
traderT
12-06-2008, 09:52 AM
Is there a way to get the datetime value based on other criteria. For example ...
if(low[0] < AValue)
{
dateTimeVar = DateTime
}
// and then populate the dateTimeVar into new DateTime
barsAgoX = GetBar(new DateTime(dateTimeVar));
My other question is that I like to have otherdateTimeVar as an input - what type of variable would it be and would I have to (how?) convert it to make it work in ....
barsAgoA = GetBar(new DateTime(otherdateTimeVar));
NinjaTrader_Ray
12-06-2008, 04:04 PM
Is there a way to get the datetime value based on other criteria. For example ...
if(low[0] < AValue)
{
dateTimeVar = DateTime
}
Sure
if(low[0] < AValue)
{
dateTimeVar = Time[0];
}
On your second question, create an input of type DateTime. Here is a reference sample on creating user defined inputs.
http://www.ninjatrader-support2.com/vb/showthread.php?t=5782
traderT
12-06-2008, 06:43 PM
Thanks NT_Ray, much appreciated. I tried to apply what you said, but the results I am getting don't seem right...
if((BBA ==1)
&& (Low[0] <= BullB))
{
BBB = Time[0];
barsAgoB = GetBar(BBB);
Print(BBB);
Print(barsAgoB);
}
DrawLine("Btag", barsAgoA, High[barsAgoA], (barsAgoB), Low[barsAgoB], Color.Red);
The print(bbb) gives me the correct time , but the format of that time is different from what I have seen used with the getbar statement.
//Print results
05/12/2008 20:23:00
0
The 0 should actually correspond to the getbar of 20:23, but the output is 0
For example, this gives me the correct BarsAgoA result ...
barsAgoA = GetBar(new DateTime(2008, 12, 05, 20, 19, 0));
The getbar result for this is 22, which is correct.
Am I using the getbar incorrectly with the suggestion that you posted? If so, how can I fix it?
NinjaTrader_Bertrand
12-08-2008, 06:48 AM
Hi traderT,
hard to judge for us with only a snapshot of your custom code present, if GetBar returns a 0 it means you pass in a time that is newer than the last bar...
http://www.ninjatrader-support.com/HelpGuideV6/GetBar.html
traderT
12-08-2008, 07:50 AM
Thanks for the reply. I have found a different, though not as good way to do things. Currently my code is a mess (well, it's always a mess). However, there is light at the end of the tunnel and I will hopefully post the code either later this week or on the weekend. I am sure that there is a better way to code what I am trying to do and hopefully when I post my code, more suggestions will be forthcoming. Thanks for the help. When I have time I will explain the getbar query better.