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
last price greater then high of bar
Collapse
X
-
Hello hansob3,
Thank you for your post.
OnMarketData() will actually be called after OnBarUpdate() and therefore would not have the last price above the High[0] unless the OnMarketData() was updating outside the Trading Hours Template defined start and end times (which is the only time OnBarUpdate() is called).
Please let me know if you have any questions.
-
Here is a snippet of the debug output where I am having an issue.
2018-03-09 06:31:58:451 OnMarketUpdate:
CurrentBar: 825
Price: 2740.25
Vol: 2
Bid: 2740 - Ask: 2740.25
2018-03-09 06:31:58:451 Bar Added - Down to Up
Last Price: 2740.25
Reversal Price: 2740.25
2018-03-09 06:31:58:451 OnBarUpdate:
CurrentBar: 826
The timestamps are identical but the Bar added needs to come first in the sequence. I have a modified Point and Figure that I use but the logic of when a bar is created is the same as the builtin version. In the attached screenshot you can see the high/close of the bar but yet I get a tick above printed. Those 2 lots should be the beginning of the next bar.
My thinking is that the Bars would generate the events that the indicators would consume.
Comment
-
Hello hansob3,
Thank you for your response.
Are you building your own bar type here or using an indicator to render the bars?
Can you attach your script to your response?
You can export your file by going to Tools > Export > NinjaScript Add On > Add > select your file > OK > Export > name the file 'NTsupport' > Save.
The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript. Please attach the file to your response.
I look forward to your response.
Comment
-
I use a modified point and figure to build the bars. I tried exporting but I get an error about DayBarsType(), MinuteBarsType(), ... not in the assembly. It is in the initial lookback days method. All I did was copy the original Point and Figure but changed some of the logic but I did not change any of the logic that decides when a new bar should be added. I added a print statement to print right after the AddBar is called. I use the close, 1 tick 4 box reversal with a base period of 1 tick and tick replay checked. I do not break on EOD.
Attached is a test script that I made to go with the bars that allows you to see the debug messages.
I am using an indicator to render the volume numbers on the chart. I would like to do it as a bar type.
I forgot to mention that this happens on every bar, just easier to see when its above the high/low.Attached FilesLast edited by hansob3; 03-09-2018, 12:21 PM.
Comment
-
Hello hansob3,
Thank you for your patience.
Here is an excerpt from my Output:
OnBarUpdate:
CurrentBar: 286
OnMarketData:
CurrentBar: 286
Price: 2786.75
Vol: 1
High: 2789.75 - Low: 2784.75
Bid: 2786.75 - Ask: 2787
OnBarUpdate:
CurrentBar: 287
OnMarketData:
CurrentBar: 287
Price: 2787
Vol: 5
High: 2786.75 - Low: 2785.25
Bid: 2786.75 - Ask: 2787
OnBarUpdate:
CurrentBar: 287
OnMarketData:
CurrentBar: 287
Price: 2787
Vol: 1
High: 2786.75 - Low: 2785.25
Bid: 2786.75 - Ask: 2787
I look forward to your response.
Comment
-
The issue I am having is that the AddBar method within the bar type is not called before the OnBarUpdate within the indicator. I have attached the bar type that I use. If you use that bar type with the previous indicator you get the results that I originally posted.
So my question is shouldn't the bar type AddBar be called before calling the OnBarUpdate within the indicator? In the sequence of events it shows that even though the price has met the if statement within the bar type to add a bar it is not called till after the OnBarUpdate and OnMarketData events are called.
Thanks
BryanAttached Files
Comment
-
See attachment.
Take the example at the 2018-03-14 07:35:30:272 mark. That line is printed out when a new bar is added. You can see the last price is 2781 and that matches the reversal price, hence the new bar. If you take a look a few lines above you see the OnMarketData event with that same price, that tick should have triggered the AddBar and that OnMarketData event should be the first tick on the newly added bar.
Thanks,
BryanLast edited by hansob3; 03-14-2018, 07:12 AM.
Comment
-
Hello hansob3,
Thank you for your response.
Your Logged details show that the 2781 price level triggering the AddBar is called first as seen below:
2018-03-14 07:35:30:272 Bar Added - Up to Down
Last Price: 2781
Reversal Price: 2781
2018-03-14 07:35:30:272 OnBarUpdate:
CurrentBar: 1495
2018-03-14 07:35:30:272 OnMarketData:
CurrentBar: 1495
Price: 2781
Vol: 1
High: 2781 - Low: 2781
Bid: 2781 - Ask: 2781.25
Do you have an example where the AddBar is shown last and the next OnBarUpdate and the next OnMarketData calls are not the exact same price?
I look forward to your response.
Comment
-
Attached is another log with timestamps. Take a look at the very last one in the file. Timestamp: 2018-03-15 12:48:53:780
2018-03-15 12:48:53:780 OnBarUpdate:
CurrentBar: 476
Time: 636567149322030000
2018-03-15 12:48:53:780 OnMarketData:
CurrentBar: 476
Price: 2751.75
Vol: 1
High: 2752.75 - Low: 2752
Bid: 2751.75 - Ask: 2752
Time: 636567149322030000
2018-03-15 12:48:53:835 Bar Added - Up to Down
Last Price: 2751.75
Reversal Price: 2751.75
Time: 636567149322260000
2018-03-15 12:48:53:835 OnBarUpdate:
CurrentBar: 477
Time: 636567149322260000
2018-03-15 12:48:53:835 OnMarketData:
CurrentBar: 477
Price: 2752
Vol: 1
High: 2751.75 - Low: 2751.75
Bid: 2751.75 - Ask: 2752
Time: 636567149322260000While that same price is seen in a bar update and market data update directly before does not suggest that it is what called the AddBar.
A tick came in at 2751.75 and was added to bar 467, but that same tick is what triggers the AddBar logic. Shouldn't that tick that came in fire the AddBar logic before is reaches the OnBarUpdate and MarketData events? What event triggers the OnBarUpdate?Attached Files
Comment
-
Hello hansob3,
Thank you for your response.
AddBar() is called in OnDataPoint() based on the BarsTypes' logic in OnDataPoint().
I am only able to see this behavior with your BarsType which is just the PointAndFigureBarsType. I will continue to test further and follow up with you when I have any details.
Comment
-
Hello hansob3,
Thank you for your patience.
This occurs when the tick has the same price level for the last tick of the bar and the tick of the new bar. AddBar triggers the OnBarUpdate call and we known that OnMarketData will be called after OnBarUpdate. The behavior you are seeing is expected and in the proper sequence.
Please let me know if you have any questions.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ageeholdings, 05-01-2024, 05:22 AM
|
6 responses
42 views
0 likes
|
Last Post
by ageeholdings
Today, 08:37 PM
|
||
Started by tony_28217, Today, 07:04 PM
|
0 responses
8 views
0 likes
|
Last Post
by tony_28217
Today, 07:04 PM
|
||
Started by flybuzz, Today, 10:33 AM
|
1 response
9 views
0 likes
|
Last Post
by flybuzz
Today, 06:59 PM
|
||
Started by spencerp92, 10-10-2023, 09:56 AM
|
4 responses
308 views
0 likes
|
Last Post
by flybuzz
Today, 06:45 PM
|
||
Started by samish18, Yesterday, 10:13 AM
|
1 response
26 views
0 likes
|
Last Post Today, 06:15 PM |
Comment