If possible, I would like to determine and display whether the high of that first leg was further up or down after the second leg.
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
The previous day's one-minute decision
Collapse
X
-
The previous day's one-minute decision
I would like to determine whether the first 1 minute leg of the previous day was positive or negative and display that in the market analyzer.
If possible, I would like to determine and display whether the high of that first leg was further up or down after the second leg.Tags: None
-
Hello ラリー,
For this type of logic you would need to use an indicator so that you could load enough data/bars to account for a previous session.
An indicator processes data from the first bar up until now in time so this type of logic could be done by leveraging the IsFirstBarOfSession property to do a reset. Here is a quick example of maintaining a value from the previous day during the current trading session. This logic would repeat for each new session and reset the prior day value so it can be plotted.
Code:private double priorDayValue; private double currentDayValue; protected override void OnBarUpdate() { if(Bars.IsFirstBarOfSession) { priorDayValue = currentDayValue; } Value[0] = priorDayValue; //logic to find first minute value or whatever logic you wanted if(Close[0] < Open[0]) { currentDayValue = -1; } else if(Close[0] > Open[0]) { currentDayValue = 1; } }
JesseNinjaTrader Customer Service
-
Hello ラリー,
The 3 dots generally means that it is waiting for a value.
I would suggest testing this type of logic from a chart before moving to the analyzer to make sure what you made is working well. Once you can visually see that the plot is the value you had intended you could move to testing in the analyzer. With the analyzer you also need to make sure enough data has been loaded, the analyzer by default tries to load minimal data.
JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
I am attaching my progress.
I did a test on the chart when the market started and nothing is showing, nor is it showing in the market analyzer.
Could it be, but I'm not sure, that it didn't show up because there is no plot?
If so, I don't know much about ninja scripts and such, so I would appreciate it if you could help me out with the plots as well.
Comment
-
Hello ラリー,
You need to add a plot in order to plot data, you would need to use AddPlot in the indicator.
This also requires historical data to process at least 1 session before the current so that the previous session value could be used.
After adding a plot you would need to remove and re apply the indicator so that can be used.
I would suggest to avoid the analyzer until you have verified that the script is working from a chart.JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
I have written the referenced plot statement from the link, is this correct?
I also applied it to the market analyzer and it displayed 1 and -1, but is it possible to change this to any string or something else?
Also, it seems that the close leg includes the second half of the day, but is it possible to apply it only to the first half of the day?
Thank you in advance for your time and patience.
Comment
-
Hello ラリー
If you see the plot and there are no errors then the changes you made a re correct.
Indicators in the analyzer can only report price values so if you wanted text you would need to create cell conditions using the market analyzer to check for -1 and 1.
Also, it seems that the close leg includes the second half of the day, but is it possible to apply it only to the first half of the day?
JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
Yes, there does not seem to be an error.
Also, I was able to change the text from cell to any text in the Market Analyzer.
Yes, I would like to determine if it is positive or negative and display it in the Market Analyzer using only the first closing leg of the previous day's 1 minute.
Comment
-
Hello ラリー,
Yes, I would like to determine if it is positive or negative and display it in the Market Analyzer using only the first closing leg of the previous day's 1 minute.
The code that I provided was only an example of how to plot something continuously for 1 day based on the prior session, the plot is only reset on the first bar of the session:
Code:if(Bars.IsFirstBarOfSession) { priorDayValue = currentDayValue; }
The calculation that I had shown would have to be changed to suit your needs depending on the bar type you are using. I just provided a simple greater or lesser condition to show how to plot. To do this for the first one minute depends on the bars type that you will be using.
Code:/[B]/logic to find first minute value or whatever logic you wanted[/B] if(Close[0] < Open[0]) { currentDayValue = -1; } else if(Close[0] > Open[0]) { currentDayValue = 1; }
Code:if(Close[0] < Open[0] && Bars.IsFirstBarOfSession) { currentDayValue = -1; } else if(Close[0] > Open[0] && Bars.IsFirstBarOfSession) { currentDayValue = 1; }
JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
We have made the changes to the code you sent us, but it seems that the later session is also included in the display.
I guess there is no lunch break or rest time in the US market, but in Tokyo Stock Exchange, there is a lunch break from 9:00 to 11:30, and the second session is from 12:30 to 15:00, but it seems that the time at 12:30 in the second session is also included as a session time in the calculation.
In other words, you want to perform the calculation based on the morning session only, not including the afternoon session.
Comment
-
Hello ラリー,
If you are using an instrument with multiple sessions in one day then you will hit the first bar of the session each time a new session starts. For that instrument you may be better of using a time condition instead of IsFirstBarOfSession for the reset. https://ninjatrader.com/support/help...ightsub=totime
Most instruments have a specific start and end time without having two defined sessions in one day so you can logically use the first bar of session to know that is the only first bar.
JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
If you are using an instrument with multiple sessions in one day then you will hit the first bar of the session each time a new session starts.
Yes, I believe that is the case.
So I tried the example link you sent, but when I hover the cursor over any position on the chart, it only shows 0 in the data box.
Are my changes to rows 64 and 68 correct?
Comment
-
Hello ラリー,
To have the reset happen at a specific time you would need to change the
Code:if([B]Bars.IsFirstBarOfSession[/B]) { priorDayValue = currentDayValue; }
The other conditions to set the value up or down would still need to be changed to whatever works for the bars type you used. I provided an example of what that would look like on a 1 minute series but that uses IsFirstBarOfSession as well. You could use time conditions there as well but you also need the conditions checking if the price is up or down like it was originally.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
9 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
||
Started by junkone, 04-21-2024, 07:17 AM
|
9 responses
68 views
0 likes
|
Last Post
by jeronymite
Yesterday, 11:51 PM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
4 responses
20 views
0 likes
|
Last Post Yesterday, 10:33 PM | ||
Started by mgco4you, Yesterday, 09:46 PM
|
1 response
11 views
0 likes
|
Last Post Yesterday, 09:56 PM |
Comment