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
Daily loss limit examples
Collapse
X
-
Can someone please advise best way to open those files as its doesn't add up for me?
-
Hi Pavan, thanks for posting. All of the strategy files in the first post should be working properly. Could you please detail what exactly is not working? Are you not able to enable the strategy, or does it get enabled, but you are seeing unexpected output?
Leave a comment:
-
Wihich file is working in the above links? I am. trying to enable and it just doesnt work.
Leave a comment:
-
Hi rht5692, for questions related to help with customizing an example, please create a new topic and explain your question in as much detail as possible. It is going to be difficult to answer your question and understand the trouble you are having with this little detail about your question in this post.
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello,
I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8.
These are often requested and I felt they are good examples to have for NT8.
DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241
DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367
Update Sep 4th, 2018:
- I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.
Update July 13th, 2020:
- Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.
Leave a comment:
-
Hi tkaboris, thanks for writing in. Its best to override OnPositionUpdate because this event triggers when there is any change in the strategy position. It can be done in OnOrderUpdate but you would need some extra steps such as checking the current and last position held, also checking if the order is an exit order or an entry order, and so on. You can add OnPositionUpdate to your script.
Leave a comment:
-
in my strategy there is no ONPositionUpdate, only onORderupdate. Can this logic that is below be used in onOrderUdate instread?
I want to add daily stop loss limit
protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition)
{
if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
{
// when a position is closed, add the last trade's Profit to the currentPnL
currentPnL += SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency;
// print to output window if the daily limit is hit
if (currentPnL <= -LossLimit)
{
Print("daily limit hit, no new orders" + Time[0].ToString());
}
}
}
Leave a comment:
-
Hello grimes12 and Steve4616,
Thanks for your notes.
grimes12:
"what is the difference between the "Daily Loss Limit Example_NT8" and "Daily Loss Limit MultiTrade Example_NT8"?"
DailyLossLimitMultiTradeExample calls EnterLong() multiple times using separate signal names ("long1" and "long2"). DailyLossLimit_NT8 calls EnterLong() once using one signal name ("long1"). This could be seen by viewing and comparing each script's code and noting the differences between the two.
Steve4616:
" should it close the current position when it hits that target? Also, the default number is 100, is that ticks? Points? or Dollars?"
When the CrossAbove condition becomes true and CurrentBars is greater than 20 and DailyPNL is greater than DailyLoss, the strategy will call EnterLong() to place a long Entry order. When the CrossBelow condition becomes true and CurrentBars is greater than 20 and DailyPNL is greater than DailyLoss, the strategy will call EnterShort() to reverse positions so that you end up in a short position.
The DailyLoss default value refers to currency (Dollars).
"under set 4 it says "CurrentBars{Default input} >20". What is the purpose of this statement?"
This condition checks if the CurrentBars value is greater than 20 to ensure that at least 20 bars have been processed before trades are placed.
Let me know if I may further assist.
Leave a comment:
-
Originally posted by Steve4616 View Post
With the "DailyLossLimitBuilderExample_NT8" should it close the current position when it hits that target? Also, the default number is 100, is that ticks? Points? or Dollars? Thanks
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello,
I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8.
These are often requested and I felt they are good examples to have for NT8.
DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241
DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367
Update Sep 4th, 2018:
- I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.
Update July 13th, 2020:
- Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.
Leave a comment:
-
Originally posted by NinjaTrader_BrandonH View PostHello afisher1965 and grimes12,
Thanks for your notes.
afisher1965:
You could download and view the DailyLossLimit example scripts created by my colleague Chelsea attached in post # 1 on page 1 of this forum thread.
grimes12:
First, download the example script from post # 1 on page 1 of this forum thread. After downloading the file, open NinjaTrader and go to Tools > Import > NinjaScript Addon. To use the strategy, open a New > Chart window and enable the strategy on the chart. Note that this is a sample script demonstrating the concept of how to code a daily loss limit in a NinjaScript. This is not a fully functioning out-of-the-box strategy.
See this help guide page: https://ninjatrader.com/support/help...t_strategy.htm
Let me know if I may assist further.
But what is the difference between the "Daily Loss Limit Example_NT8" and "Daily Loss Limit MultiTrade Example_NT8"? When I load both strategies, I same no difference in terms of properties. Please help me understand.
Leave a comment:
-
Hello afisher1965 and grimes12,
Thanks for your notes.
afisher1965:
You could download and view the DailyLossLimit example scripts created by my colleague Chelsea attached in post # 1 on page 1 of this forum thread.
grimes12:
First, download the example script from post # 1 on page 1 of this forum thread. After downloading the file, open NinjaTrader and go to Tools > Import > NinjaScript Addon. To use the strategy, open a New > Chart window and enable the strategy on the chart. Note that this is a sample script demonstrating the concept of how to code a daily loss limit in a NinjaScript. This is not a fully functioning out-of-the-box strategy.
See this help guide page: https://ninjatrader.com/support/help...t_strategy.htm
Let me know if I may assist further.
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello,
I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8.
These are often requested and I felt they are good examples to have for NT8.
DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241
DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367
Update Sep 4th, 2018:
- I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.
Update July 13th, 2020:
- Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.
Leave a comment:
-
Does anybody has a working code that sets a Daily Max Loss?
Thank You
- Likes 2
Leave a comment:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
3 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Leave a comment: