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

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


  • NinjaTrader_BrandonH
    replied
    Hello MatthewLesko,

    Thanks for your note.

    Unfortunately, we do not have a reference sample that demonstrates making a Daily Profit Limit.

    That said, you could use the same concept as the Daily Loss Limit reference samples to create a Daily Profit Limit in your strategy.

    Essentially, you would create a DailyProfit variable in your script similar to the DailyLoss variable in the DailyLossLimit script. Then, you would create a condition that compares DailyPNL to your DailyProfit variable.

    Let me know if I may assist further.

    Leave a comment:


  • MatthewLesko
    replied
    Hi is there an option with this to stop trading if reached a profit as well?

    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello burmaz,

    Thanks for your note.

    I am not aware of anything in that example script that would need to occur at the close of a bar.

    The DailyLossLimitBuilderExample script should work with either Calculate.OnPriceChange or Calculate.OnEachTick.

    You would change the Calculate mode to OnPriceChange or OnEachTick when enabling the strategy.

    Let me know if I may assist further.

    Leave a comment:


  • burmaz
    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.


    Hello,

    What changes do I make in the strategy builder so that the "DailyLossLimitBuilderExample" attached file will work 'on price change' or on 'each tick' (intrabar)instead of on bar close? It works fine on bar close but I want it to operate with intrabar.

    Leave a comment:


  • Steve4616
    replied
    Originally posted by NinjaTrader_BrandonH View Post
    Hello Steve4616,

    Thanks for your post.

    This feature request has not yet been implemented into NinjaTrader. I have added your note to the feature request to include a Daily Profit Limit as well as a Daily Loss Limit in the Strategy Builder.

    Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
    • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
    • Feasibility
    • Developer bandwidth
    • Current projects in the queue
    • Economics
    You'll find a note regarding your feature request in the release notes when a feature is implemented.

    Let me know if I may assist further.
    Thanks Brandon

    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello Steve4616,

    Thanks for your post.

    This feature request has not yet been implemented into NinjaTrader. I have added your note to the feature request to include a Daily Profit Limit as well as a Daily Loss Limit in the Strategy Builder.

    Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
    • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
    • Feasibility
    • Developer bandwidth
    • Current projects in the queue
    • Economics
    You'll find a note regarding your feature request in the release notes when a feature is implemented.

    Let me know if I may assist further.

    Leave a comment:


  • Steve4616
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello Trader17,

    I have received tracking ID# SFT-2936 for this request for a daily loss limit built into NinjaScript Strategies.

    Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

    We appreciate your feedback on this.
    Did this ever get developed? If not, can we change the request to include a Daily Profit to it as well. Would be nice to just go to "Options" under "Tools" and select which account, and then a daily profit target and a daily stop loss. If either is met(Realized + Unrealized) then it flattens all positions and disables all the strategies for that account

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello howardtrade,

    If you set the strategy to calculate OnPriceChange or OnEachTick, OnBarUpdate will update with each tick or price change after it is processing realtime data. Please note that BarsAgo 0 references would then reflect the developing bar rather than the bar that has just closed. If you need to separate logic in an OnEachTick/OnPriceChange strategy so it happens on bar closures, you can use IsFirstTickOfBar and check BarsAgo 1 references to get the bar close values when a bar closes.

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    Without making modifications to DailyLossLimitMultiTradeExample, we do not get an error on line 63 "entryOrders = new Order[3];" This creates an array of orders which is used in the strategy for order tracking. If you would like to learn more about arrays, I suggest reviewing publicly available C# materials on arrays. If you would like to learn more above using Order objects, I suggest reviewing the SampleOnOrderUpdate strategy and associated documentation.

    Arrays (publicly available C# resource) - https://www.tutorialspoint.com/csharp/csharp_arrays.htm

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    We look forward to assisting.

    Leave a comment:


  • howardtrade
    replied
    Hi,

    Thanks for the example. Just curious if theres a calculate on each tick example available?

    Also, can you please explain what this line is for?

    Code:
    entryOrders = new Order[3];
    when set to 3, I receive an error in the output window "Error on calling 'OnBarUpdate' method on bar 1934: Index was outside the bounds of the array"

    I have 3 entry orders per direction.

    when set to 7 the strategy runs, but the results and daily loss math don't seem to add up correctly.

    Thanks!

    Leave a comment:


  • MathWiz
    replied
    I'm looking for a more streamlined version of the max account profit and loss strategy. I start each day with clean new strategy enabled so my currentpnl is always starting at 0. I see there is mention above of a much easier version if each day already starts at 0, but don;t see any link to one. Anyone have one?

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Welcome to the forums TheTradingNetwork!


    There would not be a parameter to add, the logic will have to be created in the Strategy Builder. Please see post 1 for the DailyLossLimitMultiTradeExample_NT8 example to see how this logic can be set up.

    We look forward to assisting.

    Leave a comment:


  • TheTradingNetwork
    replied
    Hey everyone, I'm curious if it's possible to do something like this directly inside the strategy builder without manually coding it? For instance if I have a strategy working properly from the Strategy Builder, is there a way to allow for the ability of a daily loss limit or profit limit with a combination of the strategy builder parameters?

    TIA

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello jpatri,

    There is no ETA and feature requests are tracked internally as the requests often contain internal discussion which we would not want to have public facing.

    Feature Request Disclaimer.

    We receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing.

    When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number will be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

    Release Notes -
    https://ninjatrader.com/support/help...ease_notes.htm

    Let us know if you have any questions.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by PaulMohn, Today, 03:49 AM
0 responses
7 views
0 likes
Last Post PaulMohn  
Started by inanazsocial, Today, 01:15 AM
1 response
9 views
0 likes
Last Post NinjaTrader_Jason  
Started by rocketman7, Today, 02:12 AM
0 responses
10 views
0 likes
Last Post rocketman7  
Started by dustydbayer, Today, 01:59 AM
0 responses
4 views
0 likes
Last Post dustydbayer  
Started by trilliantrader, 04-18-2024, 08:16 AM
5 responses
23 views
0 likes
Last Post trilliantrader  
Working...
X