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
Positive or negative opening price of the previous day
Collapse
X
-
Hello ラリー,
Thank you for clarifying.
I am not aware of an existing Market Analyzer column or indicator that would accomplish this. That being said, this should be possible using a custom NinjaScript add-on. If you have a programming background, our team may provide you links to samples that would help you write the add-on yourself, or we can provide you with resources to find a programmer to create the add-on for you.
Please let me know if one of these options interests you and I would be glad to follow up accordingly.Emily C.NinjaTrader Customer Service
Comment
-
Hello ラリー,
Thank you for your reply.
For any user getting started with NinjaScript, I recommend reviewing the following link which has many useful NinjaScript and C# resources:
https://ninjatrader.com/support/foru...pts#post786040
There are many ways you could show in the Market Analyzer if the previous day's open price was a positive bar or a negative bar. One way to do this is to code a custom indicator which may then be added via an Indicator column in the Market Analyzer. I have created a snippet that checks if IsFirstBarOfSession is true and whether the Close of that bar is greater than or less than the Open of that bar. It then sets a bool, positiveOpen, to true or false depending on whether the bar was positive or negative. I created a Series<double> called openBar that equals 1 when the positiveOpen bool is true and -1 when the bool is false. Then, the plot value is set based on the value of openBar, and the plot colors are LimeGreen or Red based on if it is greater than 0 or less than 0. You could add this indicator to a Market Analyzer column and set the "Type" dropdown to bar graph in order to view the green or red from the plot. Here is the snippet:
Code:private Series<double> openBar; private bool positiveOpen; protected override void OnStateChange() { if (State == State.SetDefaults) { AddPlot(new Stroke(Brushes.Black, 2), PlotStyle.Bar, "OpenBarPlot"); } else if (State == State.DataLoaded) { openBar = new Series<double>(this); } } protected override void OnBarUpdate() { if (CurrentBar < 1) return; if (Bars.IsFirstBarOfSession && Close[0] > Open[0]) positiveOpen = true; if (Bars.IsFirstBarOfSession && Close[0] < Open[0]) positiveOpen = false; if (positiveOpen == true) openBar[0] = 1; if (positiveOpen == false) openBar[0] = -1; OpenBarPlot[0] = openBar[0]; if (openBar[0] > 0) PlotBrushes[0][0] = Brushes.LimeGreen; else if (openBar[0] < 0) PlotBrushes[0][0] = Brushes.Red; else PlotBrushes[0][0] = Brushes.Black; }
https://www.screencast.com/t/hdf0pyLMDc
Please try these ideas out on your own and let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
-
Hello ラリー,
Thank you for your reply.
Did you add the plot via the New Indicator wizard? Any plots added require additional logic in the Properties region of the script, and the wizard adds this logic for you. For example:
Code:[Browsable(false)] [XmlIgnore] public Series<double> OpenBarPlot { get { return Values[0]; } }
It is mentioned in the Tips for AddPlot() that we suggest using the NinjaScript wizard to generate plots:
https://ninjatrader.com/support/help...t8/addplot.htm
Please try creating the indicator again and add the plot in the wizard and this should resolve the errors.
THank you for your time and patience.Emily C.NinjaTrader Customer Service
Comment
-
Hello Larry,
Thank you for your reply.
I see you added a plot called "My" but I suspect that "OpenBarPlot" was still copied/pasted and not created via the wizard. If you look near the bottom of your script, the "My" plot should have some information in the Properties region of your script. "OpenBarPlot" will need the same information added in order to resolve the error message.
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
-
Thank you for your reply.
I have created the indicator file from here (attached) and copied and pasted the code you provided within Ninja Script, but are you saying that the attached screenshot here is not the wizard?
Also, I understand that the same information needs to be added to the "OpenBarPlot", is this done within Ninja Script?
Comment
-
Hello ラリー,
Thank you for your reply.
Yes, the image in your screenshot is from the Indicator wizard. The code snippet I provided was not intended to just copy/paste and then work right away; it was provided as a starting point and an example of the logic you could use while creating your own indicator. It is meant to be used as an educational resource so that you may develop the indicator yourself. If you would prefer, we could gladly provide you with more information to contact a NinjaScript consultant for hands-on educational services or a developer who could code this for you.
The same information for "OpenBarPlot" could be done within NinjaScript (per my response in post number 8), although it would be more simple to start a new indicator and add a plot with that name from the Wizard as shown in your screenshot, then you could use the snippet I provided as an idea when coding within the indicator that you create.
Thank you for your patience.Emily C.NinjaTrader Customer Service
Comment
-
Comment
-
Code:名前空間 NinjaTrader.NinjaScript.Indicators { public class MyCustomIndicator : Indicator { [Browsable(false)] [XmlIgnore] public Series<double> OpenBarPlot { get { return Values[0]; } } プライベート Series<double> openBar; private bool positiveOpen; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"新しいカスタム インジケーターの説明をここに入力してください。"; 名前 = "MyCustomIndicator"; 計算 = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //新しい市場データ イベントごとに累積するカスタム値が指標に必要な場合は、このプロパティを無効にします。 //詳細については、ヘルプ ガイドを参照してください。 IsSuspendedWhileInactive = true; //AddPlot(Brushes.Orange, "My"); AddPlot(new Stroke(Brushes.Black, 2), PlotStyle.Bar, "OpenBarPlot"); } else if (State == State.DataLoaded) { openBar = new Series<double>(this); } } 保護されたオーバーライド void OnBarUpdate() { if (CurrentBar < 1) return; if (Bars.IsFirstBarOfSession && Close[0] > Open[0]) ポジティブオープン = 真; if (Bars.IsFirstBarOfSession && Close[0] < Open[0]) positiveOpen = false; if (positiveOpen == true) openBar[0] = 1; if (positiveOpen == false) openBar[0] = -1; OpenBarPlot[0] = openBar[0]; if (openBar[0] > 0) PlotBrushes[0][0] = Brushes.LimeGreen; そうでなければ (openBar[0] < 0) PlotBrushes[0][0] = Brushes.Red; そうでなければ PlotBrushes[0][0] = Brushes.Black; // カスタム インジケーター ロジックをここに追加します。 } #領域プロパティ [Browsable(false)] [XmlIgnore] public Series<double> My { get { return Values[0]; } } #エンドリージョン } }
Last edited by ラリー; 11-29-2022, 05:09 AM.
Comment
-
Hello ラリー,,
Thank you for that information.
This may have to do with your bar graph settings; there is a "Max bar graph display value" and I believe it defaults to 1000. Since this is only plotting -1 or 1, that would barely show up on a scale of 1000. Please try setting this to a smaller number, like 5, then apply the changes and see if this resolves your question about the bar graph.
Please let me know if I may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Vern10, Today, 10:51 AM
|
3 responses
16 views
0 likes
|
Last Post
|
||
Started by josh18955, Today, 11:16 AM
|
1 response
14 views
0 likes
|
Last Post
![]() |
||
Started by Malexander2023, Today, 04:40 AM
|
1 response
13 views
0 likes
|
Last Post
|
||
Started by smjfamily, Yesterday, 04:11 PM
|
1 response
59 views
0 likes
|
Last Post
|
||
Started by Uhumm, Today, 11:18 AM
|
3 responses
28 views
0 likes
|
Last Post
|
Comment