Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple strategy MACD and RSI

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

    simple strategy MACD and RSI

    I'm not a programmer and I'm trying to create a simple strategy with strategy builder just to understand how to proceed and do tests with MACD 3,14,5 and with RSI 14,3 but I don't understand what I have to include in the choices to sell or buy when my line blue goes under my yellow line or vice versa. Thanks to anyone who can help me with a practical example

    #2
    Hello trelling,

    By 'blue line' do you mean the RSI indicator RSI plot?
    By 'yellow line' do you mean the RSI indicaor Avg plot?

    Attached is a screenshot of selecting RSI on the left and selecting the RSI plot, CrossBelow in the center, and RSI with the Avg plot selected on the right.
    Click image for larger version

Name:	2024-11-29_6-47-37.png
Views:	331
Size:	26.0 KB
ID:	1326105

    We do have resources to help you begin creating NinjaScript Strategies/Indicators.

    The best way to begin learning NinjaScript is to use the Strategy Builder. With the Strategy Builder you can setup conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

    I'm also providing a link to a pre-recorded set of videos 'Automate Your Trading with NinjaTrader's Strategy Builder' and 'NinjaScript Editor 401' for you to view at your own convenience.
    Automate Your Trading with NinjaTrader's Strategy Builder
    NinjaScript Editor 401

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of support articles first:
    Basic Programming Concepts

    For general C# education I have personally found Dot Net Perls to be a great reference site with easy to understand examples.


    We also have great resources in relation to Strategy Development on our Support Forum. There is a very active developer community in our support forum that supplements the responses provided by NinjaTrader support staff providing all users with an exceptional support experience.
    Take me to your support forum!

    There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under New -> NinjaScript Editor -> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

    We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
    Click here to see examples created by the support team
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    Also, below I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript.


    Further, the following link is to our help guide with an alphabetical reference list to all supported methods, properties, and objects that are used in NinjaScript.
    Alphabetical Reference

    And our Educational Resources in the NinjaTrader 8 help guide.
    Educational Resources

    A set of specific tutorials for creating conditions in the NinjaTrader 8 Strategy Builder in the NinjaTrader 8 help guide.
    Condition Builder

    I'm also providing a link to a support article with further helpful resources on getting started with C# and NinjaScript.


    You can also contact one of our professional NinjaScript Consultants or Educators who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like a link to a list of professional affiliate NinjaScript Consultants or Educators on the NinjaTrader Ecosystem website.

    Please let me know if I may answer any specific questions for you throughout your journey of becoming a NinjaScript Developer.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      As I repeat, I am not an expert and I apologize if I bother you again but I want to understand if I have written everything correctly because then when errors appear I cannot resolve them. Look at everything, then to buy cross above and to sell cross below with 3,14,5 and 14.3.

      Ps Then there will be the problem of how to close if the blue line passes below or above the yellow.
      Last edited by trelling; 11-30-2024, 04:05 AM.

      Comment


        #4
        Hello trelling,

        "I want to understand if I have written everything correctly "

        Have you setup the cross condition as shown in the screen shot I have provided?

        "because then when errors appear I cannot resolve them."

        If you would like assistance with an error, provide the full error message.

        "Ps Then there will be the problem of how to close if the blue line passes below or above the yellow."

        The condition would be setup the same as shown in the screenshot I have provided you, but use CrossBelow instead of CrossAbove.


        You can also contact one of our professional NinjaScript Consultants or Educators who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like a link to a list of professional affiliate NinjaScript Consultants or Educators on the NinjaTrader Ecosystem website.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          For the errors I was referring to other attempts to build a strategy which I was unable to resolve. for this one after the explanation I have no errors but I can say that "It doesn't work"! I wanted to apply both indicators and as shown in the attached photo there are particularly favorable coincidences of entry. I tried the demo strategy for several hours but even though there were entry options on the video, nothing happened, it's a question of "synchronization". is there a way to synchronize, align the two indicators or is my idea wrong?
          Attached Files

          Comment


            #6
            Hello trelling,

            If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true and the order is not being submitted, or the order is being ignored for other reasons, or the order is being cancelled or rejected.

            To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

            In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.
            The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.
            The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

            Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

            I am happy to assist you with analyzing the output from the output window.

            Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

            Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


            Let me know the date and time the behavior occurred or when you are expecting the behavior to occur.

            Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print or enabling TraceOrders.​
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I tried with Playback on Friday but no orders were placed throughout the day
              Attached Files

              Comment


                #8
                Hello trelling,

                Adding prints will give you more information about what is occuring.

                In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.​

                Also, enable TraceOrders and print the order.ToString() in OnOrderUpdate().

                Once the debugging prints are added, compile and re-run the script.

                Provide the output saved to a text file with your next post.

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I don't know if I entered the print correctly but I don't see any order or error so it's impossible for me to find a solution

                  Comment


                    #10
                    Hello trelling,

                    May I confirm you have watched the 'Debugging with the Strategy Builder' video?

                    Try just printing the time of the bar.
                    Ensure the output window is open before running the script.
                    Are you seeing the time of the bar appearing?

                    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 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.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Ninjascript output i see
                      Enabling NinjaScript strategy 'MyTest/342788988' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
                      name='MyTest' id=342788988
                      name='MyTest' id=342788988
                      name='MyTest' id=342788988​

                      Comment


                        #12
                        Hello trelling,

                        May I confirm you have watched the 'Debugging with the Strategy Builder' video?

                        Are you following the steps in the video?

                        Have you added a print with the string set to Time > Date series in an empty condition set?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          yes I saw it but I am not able to add all those conditions but at the beginning you see some orders... in my strategy I don't see any orders either buying or selling for the whole day

                          Comment


                            #14
                            Hello trelling,

                            Follow the video up to the point where the bar time is added to the print string.
                            Then click OK, compile, and reload the script.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Enabling NinjaScript strategy 'MyTest/342788993' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
                              19:57:00
                              19:58:00
                              19:59:00
                              20:00:00
                              ...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              41 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              124 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              64 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              41 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