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!
See more
See less

Partner 728x90

Collapse

Daily loss limit examples

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • elic1968
    replied
    Can someone please advise best way to open those files as its doesn't add up for me?

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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:


  • pavan15589
    replied
    Wihich file is working in the above links? I am. trying to enable and it just doesnt work.

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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:


  • rht5692
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello,

    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.
    Hi, thank you for this great example. Could you tell me how to set formula on a "do the following" for my Custom serie ? i only succeed in setting the 0 value but not +1 on the last value Thank you for your help

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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:


  • tkaboris
    replied
    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:


  • NinjaTrader_BrandonH
    replied
    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:


  • Steve4616
    replied
    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
    Also, in the builder under set 4 it says "CurrentBars{Default input} >20". What is the purpose of this statement? Thanks

    Leave a comment:


  • Steve4616
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello,

    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.
    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:


  • grimes12
    replied
    Originally posted by NinjaTrader_BrandonH View Post
    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.
    Hello Brandon, I was able to enable the strategy, thanks
    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:


  • NinjaTrader_BrandonH
    replied
    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:


  • grimes12
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello,

    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.
    How do I install it? I went to Tools>Import >Ninjascript Add on, restarted the NT8 but cant find where the options are to set Daily Limits. Help Please

    Leave a comment:


  • Steve4616
    replied
    Originally posted by afisher1965 View Post
    Does anybody has a working code that sets a Daily Max Loss?
    Thank You
    I never did get the daily profit or daily loss working. Tried multiple things but no luck. I'd share if I did

    Leave a comment:


  • afisher1965
    replied
    Does anybody has a working code that sets a Daily Max Loss?
    Thank You

    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 jaybedreamin  
Started by DJ888, 04-16-2024, 06:09 PM
6 responses
18 views
0 likes
Last Post DJ888
by DJ888
 
Started by Jon17, Today, 04:33 PM
0 responses
1 view
0 likes
Last Post Jon17
by Jon17
 
Started by Javierw.ok, Today, 04:12 PM
0 responses
6 views
0 likes
Last Post Javierw.ok  
Started by timmbbo, Today, 08:59 AM
2 responses
10 views
0 likes
Last Post bltdavid  
Working...
X