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
Ninjatrader 8 help developpement
Collapse
X
-
Ninjatrader 8 help developpement
We re using ninja trader v8 and we re wondering if accessing close[0] is still the way to get current price for backtesting or real time data.Tags: None
-
Hello,
Thank you for the post.
Yes, this would still be the case. You can locate changes made to NinjaScript in the following document: http://ninjatrader.com/support/helpG...ng_changes.htm
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Ninjatrader 8 help developpement
Hello and thank you NinjaTrader_Jesse !
So,
I want to recover the price of the market in real time and test it in backtest following an intervale of 1 Ticks.
With a stopLoss definition and target has 1 and 2 ticks.
Here is the code I defined:
protect override void OnStateChange () {
**** If (state = state.configure) {
******* SetStopLoss (CalculationMode.Ticks, 2);
******* SetProfitTarget (CalculationMode.Ticks, 1);
**** }
}
protect override void OnBarUpdate () {
****** StatePrice = Close [0]; // current price in real time
****** Print ("current price =" + StatePrice);
}
Do you think my code is correct?
Comment
-
Hello ninintrade,
Thanks for the additional question.
This line has some misplaced capitalization "If (state = state.configure) {" where it should be: "if (State = State.Configure) {"
Other than that, your code looks correct for placing a static Profit Target and Stop Loss with 1 or two ticks difference in price since entry. You will still have to add entry methods to enter into the market, and you will have to assign the strategy to operate off of a single tick series or use Calculate.OnEachTick.
Please refer to the documentation below to check your syntax and to look further into using OnStateChange()
OnStateChange() - http://ninjatrader.com/support/helpG...tatechange.htm
Calculate - http://ninjatrader.com/support/helpG.../calculate.htm
Order Methods - http://ninjatrader.com/support/helpG...er_methods.htm
Please let me know if you have any questions on the material.JimNinjaTrader Customer Service
Comment
-
Hello
Thank you for answers
I would like to know how to update total net profit and display it in real time please ?
Comment
-
Hello ninintrade,
Thanks for the additional question.
So I may assist you further, could you elaborate if you are not referring to the information from the Accounts tab of the control center? You can view the Realized PnL and Unrealized PnL as it updates from there.
Accounts Tab - https://ninjatrader.com/support/help...counts_tab.htm
If you are referring to accessing these values in realtime from NinjaScript, you can use the OnAccountItemUpdate() override.
OnAccountItemUpdate() - https://ninjatrader.com/support/help...itemupdate.htm
Please let me know if I may be of further help.JimNinjaTrader Customer Service
Comment
-
Ninjatrader 8 help developpement
Hello NinjaTrader_Jim,
Thanks for the previous answer!
Also, I would like to know the meanings of:
MarketPosition.Flat
MarketPosition.Long
MarketPosition.Short
Even referring to the help guide, I didn't quite understand their function.
Comment
-
Hello ninintrade,
Thanks for writing back.
Those are property values for the MarketPosition property. They represent being in a long, short or flat market position. (You can read more about market positions here.)
You can use these property values to check the position of the strategy through the Position object. Referencing the MarketPosition from Position is as follows:
Code:if (Position.MarketPosition == MarketPosition.Flat)
Please let me know if you have any additional questions.JimNinjaTrader Customer Service
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