Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Strategy Builder

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

    Help with Strategy Builder

    I need help creating a strategy in the strategy builder please.

    Last edited by pattern; 12-18-2023, 02:55 PM.

    #2
    Hello pattern,

    Thank you for your post.

    For general information about getting started with NinjaScript and the Strategy Builder:


    The Strategy Builder webinar is an overview of all of the different pages and how to configure different conditions/actions:


    The conditions examples here should help you to understand how you can set up your desired conditions, such as comparing the 50 ema and 200 ema, checking for crossovers of the 18 and 4 emas, etc:


    There are also some action examples here:


    Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one-on-one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.

    That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one-on-one educational services.​

    Please let us know if we may be of further assistance.

    Comment


      #3
      The candle bars on the 3 min display according to the ending of each 3 min. Can you set it to display to the starting time of each 3 min instead?

      Comment


        #4
        Originally posted by pattern View Post
        The candle bars on the 3 min display according to the ending of each 3 min. Can you set it to display to the starting time of each 3 min instead?
        Are you referring to the timestamp of each bar? In NinjaTrader, timestamps are based on the time that a bar closes and this may not be changed to the starting time. More info may be found on the following page about how bars are built:


        If you are referring to something else, please provide a more detailed description and a screenshot demonstrating what you mean.
        • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
        • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
        ​Thank you for using NinjaTrader.

        Comment


          #5
          Hi Emily, Thanks for the replies,

          are you able to set the BarsInProgress within strategy builder , so without changing code? I want the order to be active for a certain number of bars

          Comment


            #6
            Originally posted by pattern View Post
            Hi Emily, Thanks for the replies,

            are you able to set the BarsInProgress within strategy builder , so without changing code? I want the order to be active for a certain number of bars
            BarsInProgress is not available in the Strategy Builder. If you want an active order to be canceled if it is not filled after a certain number of bars, you could implement a bar counter in the builder like the following example:
            with regard to the attached image: Line A is an indicator Line B is the m period MAX of line A Line C is an average of this indicator A Line D is another average of this indicator A is it possible, possibly using the strategy builder, but without adding a temporary variable, to set on the condition: line C crosses below line D


            You could also toggle a bool that becomes true when the order should be submitted, then once the bar counter hits the desired number of bars the bool could be set to false so that the condition to submit the order will no longer be true, resulting in the order being canceled.

            Please let us know if we may be of further assistance.

            Comment


              #7
              Can you help me by explaining the bool option more please? I would probably like to implement that.

              Comment


                #8
                Originally posted by pattern View Post
                Can you help me by explaining the bool option more please? I would probably like to implement that.
                Sure, I'd be glad to give an example. Below is a link to a video I created that sets a bool to true if the position is flat and if the SMA with a period of 14 crosses above the SMA with a period of 20. If the bool is true, it submits a limit order, and if the limit order is not filled within 3 bars then the bool is set to false which results in the limit order being canceled. The bool would not be set to true again until the next cross above occurs. It keeps track of the number of bars since the crossover using two custom series; one that equals the CurrentBar index and one that stores the bar index on which the crossover occurred. Using a custom series, you can do an offset to subtract and calculate the number of bars it has been since the crossover occurred. I have also attached the strategy I created in the video so you may import it into your own platform via Control Center > Tools > Import > NinjaScript AddOn and review how it is configured when you open it in your own Strategy Builder window.

                Video link - https://www.screencast.com/t/uZSoUNbEGyG

                Please let me know if I may be of further assistance.
                Attached Files

                Comment


                  #9
                  Hi Emily,
                  Thank you so much for taking the time to give me an example. I tried doing what you had shown but when looking at the chart with this strategy enabled, it shown a few wrong executions and not sure why. I am trying this on the MNQ.

                  So the conditions are that it
                  50 ema > 200 ema, 4 ema crosses above 18 ema, the crossing bar results in the close is greater than the open, between the times of 8:44 am to 2:55 pm CST.

                  It is implemented to how you shown on the bars on the video except 4 bars. I have attached my setup. Thank you so much!
                  Attached Files

                  Comment


                    #10
                    Originally posted by pattern View Post
                    Hi Emily,
                    Thank you so much for taking the time to give me an example. I tried doing what you had shown but when looking at the chart with this strategy enabled, it shown a few wrong executions and not sure why. I am trying this on the MNQ.

                    So the conditions are that it
                    50 ema > 200 ema, 4 ema crosses above 18 ema, the crossing bar results in the close is greater than the open, between the times of 8:44 am to 2:55 pm CST.

                    It is implemented to how you shown on the bars on the video except 4 bars. I have attached my setup. Thank you so much!
                    If you are seeing unexpected behavior, such as what you described as a few wrong executions, I suggest using print statements as well as enabling Trace Orders to debug your strategy's behavior.
                    The following post covers how to use prints to debug a strategy's behavior, including a video on how to add prints in the Strategy Builder:TraceOrders sends information to the NinjaScript Output window when an order is submitted, changed, canceled, rejected, etc. It may be enabled on the Default Properties screen of the Strategy Builder. More info may be found at the links below:These tools can help to understand why the unexpected executions were submitted and what parts of your strategy might need to be adjusted to prevent them from happening.

                    Please let us know if we may be of further assistance.

                    Comment


                      #11
                      Can you set an ATM in the strategy builder? Say you have 12 cons, and want to breakeven at 10 points (40 ticks) and sell 10 at 48 ticks and 2 at 60 ticks? With a stop loss for both at 26 ticks?

                      Comment


                        #12
                        Originally posted by pattern View Post
                        Can you set an ATM in the strategy builder? Say you have 12 cons, and want to breakeven at 10 points (40 ticks) and sell 10 at 48 ticks and 2 at 60 ticks? With a stop loss for both at 26 ticks?
                        No, ATM strategies are not available in the Strategy Builder. You can only use ATM strategies in an unlocked NinjaScript Strategy:Otherwise, the Strategy Builder is limited to the Stops and Targets screen for static stops/targets or a trailing stop with a static trailing distance. If you want dynamic stops/targets or would like a breakeven or breakeven then trail movement, you would have to use a workaround of Exit orders set up via the Conditions and Actions as demonstrated in the examples here:


                        Please let us know if we may be of further assistance.

                        Comment


                          #13
                          Hi Emily,

                          Thanks for the tip. I just wanted to share, I was inspired to achieve most of my goal with breakeven with this video: https://www.youtube.com/watch?v=CvUSIXXNTHw

                          Comment


                            #14
                            Hi Emily,

                            What is the probability mean in the strategy analyzer? First I thought it was percent profitable but there is already a row for that.


                            Click image for larger version

Name:	image.png
Views:	202
Size:	75.0 KB
ID:	1283226

                            Comment


                              #15
                              Hello pattern,

                              Thank you for your note.

                              I will answer your question here, though in the future please create a new forum thread for new questions that are unrelated to your initial post. This thread was about creating your strategy in the Strategy Builder, so a question about the Strategy Analyzer is a little tangential and covers a different topic. Thank you for your understanding.

                              The statistics definitions may be found in the help guide here:


                              The description for probability is as follows:
                              "This statistic determines how likely a trade is to occur that would return the same PnL as your Avg. trade. This is based on how many trade's PnL fall within a standard deviation of the Avg. trade. Student's t-distribution is used to find probability."

                              Please let us know if we may be of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              44 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              126 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              65 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              46 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X