Thanks
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
Coding Plot displacement in Ninja Script
Collapse
X
-
I don't know if I can help but you will need to be more specific - How do you want to modify it ? What do you want to do with it afterwards? and how long is 'afterwards'? Why are you only modifying it for the last few bars - this makes it unnecessarily complicated?Last edited by stocktraderbmp; 04-04-2012, 05:55 PM.
-
What I'm trying to do should not be complicated (I think). I want to make an indicator which is basically a flat line until a peak or a valley is identified. Once it's identified I want to draw a 'blip' on the flat line; but that blip will invariably be on a bar in the recent past. Something like Plot[2](blipvalue);
Thanks for replying..... I hope this explains it more clearly?
Comment
-
I have to assume that this will not be overlayed on the chart like an MA - so you could simply code your values and then use the Max - Min function when you reference the value for the plot -
In properties you would use :
[Description("")]
[GridCategory("")]
public int MyValue
{
get { return myValue; }
set { myValue = Math.Max(n, value); }
}
I don't know what your likely outputs are but if they are less than 'n' you will always plot 'n' until your 'blip' exceeds 'n' then you will get your 'spike'.
Alternatively you can use :
MyValue.Set(Math.Max(myValue, n));
Again this will plot the maximum of either n or your calculated value.
Finally you could try
x = (myValue < n) ? 0 : 1;
Here you will have already calculated myValue and you are using a condition -
If myValue is less than 'n' - plot a 0 otherwise plot a 1.
If 'n' is a calculation you will need to call it as another double first -
double n = (a + b + c )/ 100
Hope this is enough to get you started.
Ben.
Comment
-
Hawk Arps, you could set a negative displacement for your indicator for example - http://www.ninjatrader.com/support/h...splacement.htm
However, keep in mind then it would take the displacement set bars in realtime to show the value, as of course it can't predict the values needed.BertrandNinjaTrader Customer Service
Comment
-
Thanks... but the displacement is not the same for every occurrence of the signal. It appears to me that an indicator cannot be scripted to plot [n] bars ago, but only on the current bar. Therefor I decided to try the DrawLine(....) method; but it appears that only works on the price panel and not a subgraph.Is it possible to apply DrawLine(...) in an indicator panel instead of the price panel?
Comment
-
Hi Hawk Arps,
Yes, you can set DrawOnPricePanel = false; and drawings are then place in indicator panel.
To give you another idea here, there is PlotColors[][] property. The second index there is the bars ago value for the plot. Here is a simple loop that would color the plot for a few bars preceding the condition.
Code:protected override void OnBarUpdate() { if (CurrentBar < 3) return; if (Close[0] == Low[0]) { DrawTriangleDown(CurrentBar.ToString(), true, 0, High[0], Color.Green); for (int x = 0; x <= 3;x++) { PlotColors[0][x] = Color.Green; } } Plot0.Set(Close[0]); }
Ryan M.NinjaTrader Customer Service
Comment
-
It seems that example you gave will change the color of the plot several bars ago, but can I set a plot value for several bars ago.
BTW I think I can accomplish my goal for this tool using DrawOnPricePanel = false; and using the DrawLine(...) method. Thanks again.
Comment
-
Great that the line solution will work for you. Yes, you can set the value for historical bars by including a "barsAgo" value that represents the number of bars ago that you want the double value to be stored at.
This is how you format the set method for this:
DataSeries.Set(int barsAgo, double value)Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Max238, Today, 01:28 AM
|
1 response
22 views
0 likes
|
Last Post
by CactusMan
Today, 06:18 AM
|
||
Started by giulyko00, Yesterday, 12:03 PM
|
2 responses
10 views
0 likes
|
Last Post
by giulyko00
Today, 06:11 AM
|
||
Started by r68cervera, Today, 05:29 AM
|
0 responses
4 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
6 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
38 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
Comment