Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where to start if I want to create a strategy on a trading set-up?

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

    Drawing at specific price levels is controlled with the Y parameter of DrawText.
    DrawText(string tag, string text, int barsAgo, double y, Color color)

    My suggestion would only apply if there was an If block and then bar color was set by assigning a color property through BarColor. Your indicator is using another method that is not supported. Unfortunately NinjaTrader is not able to offer assistance with this third party indicator.

    One issue with your code is assigning values to variables within Initialize(). This should be done in OnBarUpdate().

    There is a reference sample on using drawing objects available here.
    Ryan M.NinjaTrader Customer Service

    Comment


      Thanks Ryan for the additional link and sample. I will give it a break as I spent over 4 hours without any success. Maybe I will trip over a code that will enlighten me in the near future. Until then my eyes need to be wide open for the prices ..

      Have a Relaxing weekend.

      Comment


        Hi Ryan

        My trillion thanks again for your help. A friend just shared a sample printing code with me. I modified it a few times and it finally works (per enclosed) .. Hurrah.

        Enjoy a Lovely weekend.
        Attached Files

        Comment


          Hi Ryan

          Believe you have had a Nice weekend. Mine was a fruitful one. I created 2 simple strategies and am sim-trading them this morning. Need to pick your brains please.

          I was trying to have a pair of breakout orders in ONE strategy (ideally) and don't know how to code it. For the interim, I created 2 strategies, ie one Buy Stop and one Sell Stop. When one of them gets triggered, I will manually cancel the other pending order. I believe NJ names it OCO if I use the ATM strategy to execute my trades. Appreciate your directing me to some sample links please. Thank you.

          Have a Great week.

          Comment


            Belecona,

            This isn't possible with our managed order system in 6.5. You would run into our internal order handling rules.


            Methods that generate orders (excluding market orders) to enter a position will be ignored if:
            • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
            • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
            • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
            This is possible with unmanaged order submission that we introduced in version 7. See here for an introduction to unmanaged orders.
            Ryan M.NinjaTrader Customer Service

            Comment


              Thanks Ryan for your speedy response (as always). Hmm, since I have no intention to switch to V7 in the very near future + my limited IT skill, I will manually manage my 2 strategies LOL!

              Continue enjoying your day.

              Comment


                Good morning Ryan

                I need your guidance please. I have been sim-trading a strategy since May and finally decided to run it live starting today. It triggered a trade minutes ago and got an Order Reject error message. Enclosed has the error messages on the log.

                I don't understand why it has been performing normal (incl entry/exit etc) for months on a sim environment and not on live for its first trade?!! Appreciate your tips on resolving it. Thank you.

                Have a Great day.
                Attached Files

                Comment


                  Hi Belecona,

                  The message you posted says that GTC(good till canceled) market orders are not supported for this instrument/broker/exchange combination.

                  You can select TimeInForce Day before you run the strategy if these order types are not supported. TimeInForce is one of the options you set at run time or you can hard code it.

                  Ryan M.NinjaTrader Customer Service

                  Comment


                    Thanks Ryan for your prompt response (as always).

                    I have a time code in the strategy. Guess it's not working for live trading.

                    Sorry that I don't understand the TimeInForce code. Are there samples that will help my understanding so that I can fix mine?

                    Appreciate your tips. Thanks.
                    Attached Files

                    Comment


                      There are unfortunately no samples for TimeInForce. It's just a way of specifying the duration of your orders.

                      GTC - Orders are good until you cancel them.
                      Day - Orders are canceled at the end of the day trading session.

                      These are the only two settings currently available. Not all instrument/broker/exchanges support both TimeInForce settings.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        Hi Ryan

                        How can I change my code so that it will be accepted as a day order (that way the system will not reject my order)?

                        Code:
                        [FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//Condition set 1 Go Long
                        [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]CrossAbove(SMA([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]), SMA([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]), [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]))
                        {
                        debug ([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Entering Long"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
                        EnterLong(longEntryID);
                        DrawArrowUp([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Long"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + CurrentBar, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], Low[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] - ([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]4[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]*TickSize), Color.Lime);
                        }
                        [/SIZE][/FONT][/SIZE][/FONT]


                        Thank you.

                        Comment


                          You can either hard code the TIF used in your initialize method()
                          TimeInForce = Cbi.TimeInForce.Day;

                          Or set from the GUI when you run the strategy. See attached screenshot.


                          Attached Files
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            I will take the second option, ie simply choose Day for Time in force LOL! Big Big Thank You to you Ryan. You have made my day!

                            Oh, I have questions on how to change my code so that it will do 2 contracts per trade. Both have the same stoploss, different profit targets and the second contract has a breakeven as well.

                            Would be great if you will direct me to some samples. FYI: The strategy is running normal on sim environ for almost a month now .. only does 1 contract trades.

                            Thank you!

                            Comment


                              Sure, Belecona.

                              See this reference sample on scaling in and out of a position.
                              Ryan M.NinjaTrader Customer Service

                              Comment


                                Thanks Ryan for the scaling sample. I had it and tried to modify my strategy with the same over the weekend. It compiled successfully and unfortunately did not trigger trades according to the entry condition + BE/trail not working.

                                I will review it again. You will hear from me if I cannot make it work LOL!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X