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

    Good afternoon

    I did an enhancement to my indicator so that the chart will not be crowded with lines and price tags. I would like to know how can I have the price staying on the top right corner for the current candle only (disappear upon candle closing) and not staying there until we have another entry alert?

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    Thank you.

    Comment


      Hi Belecona,

      It looks like you are using DrawTextFixed to draw the text. If you want to remove if the condition is no longer true, can use something like:

      if (Close[0] > Open[0])
      DrawTextFixed("tag", "text", TextPosition.TopRight);

      else
      RemoveDrawObject("tag");
      Ryan M.NinjaTrader Customer Service

      Comment


        Thanks Ryan for your prompt suggestion. I tried to add the suggested code to the existing script (per enclosed) .. different position .. not compiled successfully. Maybe you will give more specific instructions please. Thank you.

        Would be great to remove the price tag when it's not valid anymore:

        World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
        Attached Files

        Comment


          Did you try it like this:

          Code:
          if(Risingbarcolored==false)
          {	
          	DrawLine("line"+CurrentBar,false,4,SMA(BarsArray[2],7)[0]+(1*TickSize),0,SMA(BarsArray[2],7)[0]+(1*TickSize),Color.Aqua,DashStyle.Solid,2);
          	longEntryPrice = (SMA(BarsArray[2],7)[0]+(1*TickSize));//added to plot price
          	DrawTextFixed("longEntryPrice",FormatPrice(longEntryPrice),tPosition, Color.White,textFontMed,Color.Gray,Color.DarkGreen,10);
          	Risingbarcolored = true;
          	Fallingbarcolored = false;
          }
          				
          else RemoveDrawObject("longEntryPrice");
          Ryan M.NinjaTrader Customer Service

          Comment


            Actually, your logic for drawing is much earlier than that block, so may be more appropriate here. The compile error was likely due to the order you structured your if, else if, else. else will always need to be the last statement evaluated.

            Code:
            	if (SMA(BarsArray[2], 7)[0] - SMA(BarsArray[2], 3)[0] <=2*TickSize//Maximum 2 pips between MAs
            				&& Highs[2][0] > SMA(BarsArray[2], 7)[0]//Price breaks above SMA 7
            				&& Rising(SMA(BarsArray[2],7)) && Rising(SMA(BarsArray[2],3)))//both SMAs Rising
            			{
            				if(Risingbarcolored==false)
            				{	
            				DrawLine("line"+CurrentBar,false,4,SMA(BarsArray[2],7)[0]+(1*TickSize),0,SMA(BarsArray[2],7)[0]+(1*TickSize),Color.Aqua,DashStyle.Solid,2);
            				longEntryPrice = (SMA(BarsArray[2],7)[0]+(1*TickSize));//added to plot price
            				DrawTextFixed("longEntryPrice",FormatPrice(longEntryPrice),tPosition, Color.White,textFontMed,Color.Gray,Color.DarkGreen,10);
            				Risingbarcolored = true;
            				Fallingbarcolored = false;
            				}
            				
            				bullIndication.Set(true);
            				bearIndication.Set(false);
            			}	
            			
            			
            			
            			else if (SMA(BarsArray[2], 3)[0] - SMA(BarsArray[2], 7)[0] <=2*TickSize//Maximum 2 pips between MAs
            				&& Lows[2][0] < SMA(BarsArray[2], 7)[0]//Price breaks below SMA 7
            				&& Falling(SMA(BarsArray[2],7)) && Falling(SMA(BarsArray[2],3)))//both SMAs Falling
            			{
            				if(Fallingbarcolored==false)
            				{
            				DrawLine("line"+CurrentBar,false,4,SMA(BarsArray[2],7)[0]-(1*TickSize),0,SMA(BarsArray[2],7)[0]-(1*TickSize),Color.Magenta,DashStyle.Solid,2);
            				shortEntryPrice = (SMA(BarsArray[2],7)[0]-(1*TickSize));//added to plot price
            				DrawTextFixed("shortEntryPrice",FormatPrice(shortEntryPrice),tPosition,Color.White,textFontMed,Color.Gray,Color.DarkOrange,10);	
            				Fallingbarcolored = true;
            				Risingbarcolored = false;
            				}
            				
            				bullIndication.Set(false);
            				bearIndication.Set(true);
            			}	
            			
            			else RemoveDrawObject("longEntryPrice");
            Ryan M.NinjaTrader Customer Service

            Comment


              Thanks Ryan for the additional tips. Please note my update as follows:

              1. else RemoveDrawObject("longEntryPrice");/else RemoveDrawObject("shortEntryPrice")

              Revised script with the subject did compile successfully. Unfortunately, it's not plotting the price.

              2. Add else RemoveDrawObject("longEntryPrice"); at the end after if and else if (per enclosed)

              Since I cannot figure out where to add else RemoveDrawObject("shortEntryPrice");, the revised script now shows the suggested selling price until the next selling price alert. Please help.
              Attached Files

              Comment


                I see.

                else RemoveDrawObject() is convenient if the code is structured like in my previous sample. Your code is tricky because your condition for drawing is based on a bool flag that gets set in the opposite direction, so the else condition effectively triggers right away, and removes it. You also combine the conditions for long and short together by using else if, so it makes working it in a bit challenging.

                Without restructuring your logic to work in good else usage, you need to be able to define by code the exact conditions for removal.

                if (removeConditions)
                RemoveDrawObject()

                If you can simplify and have all the DrawTextFixed() logic in one condition, then the object can easily by removed using this basic structure.

                PseudoCode:
                if (DrawCondition)
                Draw;

                else
                RemoveDraw();
                Ryan M.NinjaTrader Customer Service

                Comment


                  Yes Ryan. I need to simplify my script. I removed bullIndication/bearIndication and it's plotting line/price though price refuses to disappear lol! I will continue trying or else stay with the original one. No big deal. Have a nice evening. My trillion thanks again.

                  Comment


                    Hi Ryan

                    I did it!! I added the following to the end and it's working the way I wanted .. haha ..

                    else
                    {
                    RemoveDrawObject(
                    "longEntryPrice");
                    RemoveDrawObject(
                    "shortEntryPrice");
                    }

                    Thank you.

                    Comment


                      Good morning

                      I have a question in my petite head for some time and forgot to ask earlier. It's about multi-time frame. I specified 1 and 3 minutes on the script. For example, 3 conditions on 3 minutes have to happen, then draw a line on 1 minute. What will be the impact if one has the multi-time frame indicator on a 3-Range chart and not 1 minute as stated on the script?

                      Thanks for clarifying my myth.

                      Comment


                        belecona,

                        If your indicator is adding the other data series via the Add() method, and you apply this to a range chart, the indicator will use the 1 and 3 minute data series for the calculations you added on the range chart.

                        Can you clarify if you Add() both the 1 minute or 3 minute? Or did you only specify the 3 minute for example?

                        What is the primary data series you usually run this indicator on?
                        MatthewNinjaTrader Product Management

                        Comment


                          Hi Matthew

                          Thanks for your prompt response. I have the following under protected override void Initialize ()

                          Add(PeriodType.Range,3);
                          Add(PeriodType.Range.5);

                          I stated the 5R entry conditions as BarsArray[2] and ask the system to draw line on 3R. I noticed some users put the indicator on a non-3R chart and wonder what impact will it make?

                          Comment


                            belecona,

                            The only implications I can think of would be how the data is displayed on the chart

                            When you add more than one data series to the chart, the chart will now use equidistant bar spacing. This is because there is only one time series on the chart. When using minute bars, you don't notice too much visually, however when you are using range bars, you might notice that the bars do not line up perfectly - this is because tick based intervals are going to plot when the ticks were received and might not open and close at the same exact times based on their values.

                            However, this will not affect how the indicator calculates and should not experience any issues.
                            MatthewNinjaTrader Product Management

                            Comment


                              Hi Matthew

                              Thanks for confirming my guess. Now I'm at peace .. smile ..

                              Comment


                                Good morning

                                Believe you have had a nice long weekend. I worked on the former BoolSeries strategy again .. still cannot figure out why I continue getting the same error message when I tried to compile it even the corresponding BoolSeries indicator has been compiled successfully.

                                World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


                                Is it possible to email the BoolSeries indicator to you via support (at) ninjatrader (dot) com for a quick diagnosis? Appreciate your help. Thank you.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                651 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
                                577 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X