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
Values of DynamicSRLines
Collapse
X
-
Tags: None
-
Hello johnnybegoode,
Thanks for your post.
You can check the indicator's source code to see if it exposes information through plots or creates public properties that can be accessed from other scripts.
This indicator does not add any plots, so it would have to be modified in order for a strategy to access it. Our documentation on AddPlot describes how plots can be added and how values can be set. If you right click on the Indicators folder in the NinjaScript Editor and select New Indicator, you could add a plot there and a Series<double> will be added that matches the plot name. You can then follow the syntax created by the New Indicator Wizard to add plots to this indicator, and those plots can then be accessed by the strategy.
AddPlot() - https://ninjatrader.com/support/help...t8/addplot.htm
The indicator draws lines with Draw.Line, and the information that is used to create the line would then be used to set a plot value.
Please let us know if you have any questions.JimNinjaTrader Customer Service
-
Could you show me one example like how to AddPlot for SL1,
so I could figure out the rest of them?
Thank you!
Comment
-
Hello johnnybegoode,
AddPlot can be called in OnStateChange under State.SetDefaults.
Code:protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "Examples Indicator"; // Add three plots and associated Series<double> objects AddPlot(Brushes.Blue, "PlotA"); // Defines the plot for Values[0] AddPlot(Brushes.Red, "PlotB"); // Defines the plot for Values[1] AddPlot(Brushes.Green, "PlotC"); // Defines the plot for Values[2] } }
For example, we see the line:
Draw.Line (this, "supLine"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p-((ZoneTickSize*TickSize)/2), ColorBelow, DashStyleHelper.Solid, 1);
The line is being drawn at p-((ZoneTickSize*TickSize)/2)
Each plot would need to be assigned this value. Since as a loop is used, you can use "level" when you are referencing the Values Series.
Values[level-1][0] = p-((ZoneTickSize*TickSize)/2);
If this is too difficult, I would recommend first building a simple test indicator that assigns Close[0] to Values[0][0] following the AddPlot documentation. A consultant could also be considered to make these modifications for you.
Let me know if I can be of further assistance.JimNinjaTrader Customer Service
Comment
-
johnnybegoode
did you figure this out, I am having same issues, I know how to add plot, but i have not been able to determine the plot equals
thanks
when i use Jim code
PlotA[0]=Values[level-1][0] = p-((ZoneTickSize*TickSize)/2);
i get an error "Cannot implicityly convert type double to int. An explicity conversion exists (are you missing a cast?)
thanks for any helpLast edited by DTSSTS; 09-27-2020, 12:37 PM.
Comment
-
Hello DTSSTS,
'=' is an assignment operator. This is used to assign values to a variable. '==' would be an equality operator that checks if two values are equal.
The error you are receiving would mean you are trying to assign a double to an int. These are not the same variable types and the code will not compile. If you look up the C# compile error, you can learn more about it, and also about casting.
Publicly available resources on this error and casting can be found below.
I want to make a program that converts Fahrenheit to Kelvins but in the conversion, you need to add 273.15. My current code for the conversion is int finalTemp = (temp1 - 32) * 5 / 9 + 273.15...
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Learn about casting and type conversions, such as implicit, explicit (casts), and user-defined conversions.
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
We look forward to assisting.
JimNinjaTrader Customer Service
Comment
-
Hello DTSSTS,
We must understand the code we are writing and the errors we encounter to correct an issue with the code. I am not making a direct suggestion on how to change your code since the code written should be understood.
You are combining an assignment operation and an equality check in the same line of code which would not be advised. If you want to make an equality check within an if statement, you can use the Strategy Builder to generate syntax.
The code would be similar, to use an if statement that has an equality check (not an assignment operation) in the condition.
I have also included a publicly available resource on writing conditions in C#.
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
We look forward to assisting.JimNinjaTrader Customer Service
Comment
-
Hello vcapeluto,
The indicator does not expose plots that can be referenced by a strategy.
The indicator will need to be modified so that plots are added and values would need to be assigned to the plots for use with a strategy. (Please see posts #2 and #4.)
We will leave the thread open for other community members in this thread to share if they have been successful making these modifications.JimNinjaTrader Customer Service
Comment
-
vcapeluto I move onto this indicator
https://ninjatraderecosystem.com/use...ad/swingrays2/
I did not really care for the way the other plotted the levels on the chart, I added a plot of the trigger of the levels from the Which is only one bar, then went to my coding team to extend the plots as a reference to use later, but you could probably add the 1 bar plot and then use that in a trigger of some sort
you may like this as well, does NOT add plots for Strategies etc, but displays on charts
When applied to a chart LabeledRays will render the end anchor price level for all Ray drawing objects.
Last edited by DTSSTS; 10-09-2020, 12:25 PM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cre8able, Today, 01:16 PM
|
1 response
4 views
0 likes
|
Last Post Today, 01:30 PM | ||
Started by chbruno, 04-24-2024, 04:10 PM
|
3 responses
48 views
0 likes
|
Last Post Today, 01:29 PM | ||
Started by samish18, Today, 01:01 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:25 PM | ||
Started by WHICKED, Today, 12:56 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:17 PM | ||
Started by WHICKED, Today, 12:45 PM
|
1 response
11 views
0 likes
|
Last Post Today, 01:08 PM |
Comment