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

Using the Strategy Builder is there a way of setting Indicator Line attributes?

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

    Using the Strategy Builder is there a way of setting Indicator Line attributes?

    Hi,

    I use the Strategy for as much as possible and do have to make some final locked changes to paint the background when long and short for example.

    I'm having two problems. When I load the strategy I have to change all the indicator line styles, width's colors by hand for each chart.

    That would not be as big an issue but when I save what I thought would be a template for the chart with the Strategy and the modified indicators it did not behave as I thought it would.

    How can I save a chart template with a Strategy loaded as when a new chart is created using New Duplicate, New chart or a NT restart the strategy is always gone.

    Any suggestions on who to come as close to have the strategies with my modified indicators in tact as I have 30 charts and it's taking me a long time to rebuilding these charts.

    Thank you,

    glen




    #2
    Hello glen,

    Plot colors in an indicator can be set with strategy builder. Line colors, line width, etc, cannot. But these can be set from an unlocked script.

    Are you referring to lines with AddLine() or lines drawn with Draw.Line()?

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,


      I'm referring to the standard NT Indicators SMA< EMA etc.

      I was looking for where that was done but don't see those those functions in the code.


      I see the variables being defined , the class created, the Brush methods invoked and the indicator added to the chart AddChartIndicator(EMA1)


      But no idea where those attributes are set.

      What happening is have 30 charts, with the same strategy loaded, The default colors attributes are all wrong so I load up a Unirenko chart with no indicators.

      Then load the strategy.

      Then spend a few minutes on each chart changing the colors, attributes, resizing all the non price indicators trying to save whatever I can in a template but nothing is getting saved.

      Then for a variety of reason the strategy gets deleted from the chart, a restart of NT , a symbol change, an manual order placed or closed but within a short period of time I have to redo the process over and over again. I save workspaces, indicator templates, strategy templates chart templates and starting from scratch each time.
      i
      I would like a workspace with one strategy loaded into each chart and the attributes of all the indicators when are invoked in the strategy, no indicator is put on outside of the strategy.

      I was supposed to start trading this strategy live tomorrow on 4 markets and have tested it running the rules manually every day for months and ready to try it on live markets.

      Today to get setup I have all the rules coded in the strategy and at this point I'm painting the background to indicate a short or long and send the buy/sell order to a sim account for awhile before fully automating. But really need to see those strategy generated colors in each chart because it very short term trading on fast moving markets.

      Can you please suggest how I can get setup properly with as many templates as I can and also find a way keep the strategy loaded. There will be times when I have to manually put an order in a live strategy chart window and would like to have as stable an environment as possible.

      Thank you.

      glen

      Comment


        #4
        Hello glen,

        In the Conditions & Actions page, in the Condition Builder, where you have selected SMA, check the box for 'Plot on chart', then set the color for the plot.

        Below is a link to the Strategy Builder 301 training video which demonstrates setting the color for a plot.
        https://www.youtube.com/watch?reload...XkWe0Nf&t=1950


        Unfortunately, the Strategy Builder does not allow for creating a Brush input. This would require unlocking code and coding by hand.
        https://ninjatrader.com/support/help...th_brushes.htm


        If you want to change the background color behind the bar when a condition is true, in the Strategy Builder in the actions window ('Do the following' section) select Drawing -> Set background color. (This is shown in the Strategy Builder 301 video as well)


        To save a Strategy Template, so input values are preset when adding a new instance of a strategy, in the Strategies window set the values, then in the bottom right click template -> save -> name the template Default (if you want this selected by default) -> click Save.
        https://ninjatrader.com/support/help...ategyTemplates
        https://ninjatrader.com/support/help...efaultSettings


        Manual orders will not be seen by the strategy. These will not affect the strategy position or performance.

        In an unlocked script, you can have a strategy add buttons, and use buttons to trigger the strategy to place order, so that the order affects the strategy position. This would not be possible using the Strategy Builder, and the script must be coded by hand.
        https://ninjatrader.com/support/foru...18#post1126818
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,


          Thanks very much for the response.

          Understood I set the colors in the manner you described. My problem is on the higher resolution monitor the default width of 1 is barely visible how can I change the non color properties?

          Also understood and do set the background when the long conditions are met to paint the background.

          I wanted to set the background color for every bar conditionally when long or short and your response indicates creating another Set to check for that condition, thank you for reminding me I could define a separate set for such a function. Apologies I didn't think of it at the time and it's a great suggestion.

          I'm ok with saving strategy templates it is helpful as you suggest. I was asking how I could avoid having to manually enable and frequently manually reloading a strategy within a chart?

          I was having an issue using chart trader with a strategy loaded where the strategy on the chart seemed to drop off or maybe it was disabled I will verify that when I closed a position.

          So I though as in other platforms that the strategy would be cognizant of orders placed manually, that would be a useful options to have.

          Thank you.

          glen

          Comment


            #6
            Hello glen,

            To confirm you want to change the width of a plot?

            This can be done in an unlocked script. This cannot be done in the Strategy Builder.

            MyIndicator.Plots[0].Width = 2;

            Below is a link to the help guide on Plots.
            https://ninjatrader.com/support/help.../nt8/plots.htm


            Where you have mentioned:
            "I was asking how I could avoid having to manually enable and frequently manually reloading a strategy within a chart?"

            Strategies must be manually enabled. This is by design. The user must consciously decide to turn the strategy on and have it start trading.

            You can design an addon, or indicator using the addon approach to have a script that does not have to be enabled.


            As for reloading, why are you reloading? Is there an issue you are trying to resolve?


            You must design the strategy to have buttons and place orders through the strategy.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              Width=2, awesome thank you very much that will save me a ton of manual tweaking.

              Ok that is the design to enable it each time, that's fine wasn't sure what was happening there.

              I am trying to avoid reloading the strategies. I have 10 charts setup with strategies and all the indicators setup correctly and I rebooted for another issue but had the workspaces saved and all the strategies are no longer loaded on the chart? Is it something I am doing. If you load and enable ten strategies in a chart and save the workspace and restart are those 10 strategies loaded in the charts?


              I will look for some button examples thank you for the help.

              glen
              Last edited by demarcog; 03-01-2021, 10:21 PM.

              Comment


                #8
                Hi Chelsea,

                Does this syntax look correct as it didn't change the width on the lines.
                the code contained:
                EMA1.Plots[0].Brush = Brushes.Crimson;

                And I added this line
                EMA1.Plots[0].Width = 4;


                Unfortunately I spent the last 10 years developing in javascript on a platform where autotrading has been in "beta" for 8 years when I should have been writing in csharp.

                Is there a recommended series of courses? I was in IT for years and started writing a lot of IBM Assembler and written in Python and a few other languages but would never dignify anything I've done worthy of being written by a "developer".

                Thank you

                glen

                Comment


                  #9
                  Hello glen,

                  This is Jim, responding on behalf of Chelsea who is out of the office at this time.

                  Please see the attached strategy which adds an EMA and changes the plot width.

                  Publicly available resources on C# can be found externally to NinjaTrader. Some publicly available resources can be found below. You may also find additional resources as well as online courses with further research.

                  https://www.tutorialspoint.com/csharp/index.htm

                  https://www.geeksforgeeks.org/csharp...ming-language/

                  We look forward to assisting.
                  Attached Files
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Jim,

                    Thank you very much for providing that code I appreciate it., that very helpful indeed.

                    Strange as that's what I had coded the only difference was the sequence of of I changed the width after changing the color as you sequence was the opposite which I don't think matters.

                    My apologies to you guys as it was really late after a long day and I'm new to csharp and screwed it up somehow, thanks again.

                    Also appreciate the course references.

                    glen

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by set2win, Today, 08:10 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post set2win
                    by set2win
                     
                    Started by YourDailyBread, Today, 06:40 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post YourDailyBread  
                    Started by llanqui, 11-29-2022, 07:05 PM
                    10 responses
                    53 views
                    0 likes
                    Last Post llanqui
                    by llanqui
                     
                    Started by willsims11, Today, 04:58 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post willsims11  
                    Started by supremeacvcost, Today, 04:42 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post supremeacvcost  
                    Working...
                    X