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

Streak and Stop Loss

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

    Streak and Stop Loss

    Good Morning,

    I'm trying to break losing streak in my strategy.

    I'm using the strategy builder as my programming knowledge are not good enough to do it.

    I would like your help with the following:

    1) I would like to add a condition using a variable that is 0 if the previous trade was a winner and 1 is it was a loser. If the Streak Variable = 0 it places an order, if Streak Variable = 1 it does not place an order but if It would do it the trade end as a winner and it makes the Streak Variable = 0 and it will be taken the next trade.
    I'm struggling to get it to work. I need the condition to make the variable 0 or 1, also I need this variable to change to 0 even when it does not take the trade.
    Can you please tell me how to do it?

    2) Also, I'm trying to set a stop loss that is a % of my current account value. For example, Stop loss = 3% of Account Value.

    Thank you in advance for all your help.
    Regards
    Carlos

    #2
    Hello Carlos,

    Thanks for your post.

    I do not think that you can accomplish your first objective within the strategy builder but would suggest that this would involve at best an elaborate use of bool variables to control the sequencing. They key objective of "if Streak Variable = 1 it does not place an order but if It would do it the trade end as a winner and it makes the Streak Variable = 0" would likely be the stumbling block as you would have to guess at the entry/exit and/or perform math on variables which is not available in the strategy builder.

    For #2, you would not be able to set this automatically in the strategy builder as the account value is not available.

    Please note that we do not provide programming services. We can leave this thread open for others in the community that may wish to provide this level of assistance.

    Alternatively, you may want to hire a 3rd party programmer who would be able to create a strategy to meet your needs (although not in strategy builder form). If this is of interest we can provide a link to a developers site in the Ninjatrader ecosystem.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      My programming knowledge is not very good, I used to learn php, I just came into contact with this, can you post your code?






      ​I am a programmer, good at programming, web design, software development
      Last edited by donwynne; 09-12-2022, 09:32 PM.

      Comment


        #4
        Hello donwynne,

        Thank you for your note.

        For users newer to NinjaScript or trying to learn NinjaScript, I always recommend checking out this post written by my colleague for some helpful information and resources:



        As this post is over 2 years old, I am not sure if the original poster would still have the code to share. If you have a specific question or something you are trying to achieve via NinjaScript, we would be glad to share a snippet or example as well as some resources to help you with writing the script.

        Please let us know if we may be of further assistance.
        Emily C.NinjaTrader Customer Service

        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