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
trigger MarketDataEvent
Collapse
X
-
yes, I know, and I use it for that, but in other situations I need to do some things that I also do in OnMarketData, that´s why I was wondering if I can call this method from my own code and in one sentence differenciate if is a call because of a MarketData event or a call from my own code and that will allow me to reuse some code.
Comment
-
You will not be able to trigger such an event. If you have parts of your code in OnMarketData() that you want to use elsewhere too instead of putting it in OnMarketData() you should put it in its own method. Then in OnMarketData() you can call that method. This will also allow you to call this method when you are not in OnMarketData() and from other locations as well.Josh P.NinjaTrader Customer Service
Comment
-
but, for example if I call OnmarketData from one of my methods like this
Code:[FONT=Courier New] [/FONT] MarketDataEventArgs e=[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] MarketDataEventArgs([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].MarketData,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],MarketDataType.Last,-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],DateTime.Now); OnMarketData([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],e);[/SIZE][/FONT][/SIZE][/FONT]
if e.Price>=0 //do what I have to do for MarketDataEvent
else //call from my code
Will that work or I´ll have any problem?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fredericlebre, Today, 01:19 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 01:19 AM | ||
Started by TraderJA, Today, 12:06 AM
|
0 responses
4 views
0 likes
|
Last Post
by TraderJA
Today, 12:06 AM
|
||
Started by SnailHorn, Yesterday, 10:49 PM
|
0 responses
7 views
0 likes
|
Last Post
by SnailHorn
Yesterday, 10:49 PM
|
||
Started by naanku, Yesterday, 07:25 PM
|
0 responses
8 views
0 likes
|
Last Post
by naanku
Yesterday, 07:25 PM
|
||
Started by milfocs, Yesterday, 07:23 PM
|
0 responses
6 views
0 likes
|
Last Post
by milfocs
Yesterday, 07:23 PM
|
Comment