Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting my trailstop on chart

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

    #31
    Sure, please check out the second tutorial - http://www.ninjatrader-support.com/H...verview18.html

    When you create a custom indicator, NinjaScript automatically prepares what other platforms call a function (method in NT), for example SMA is an indicator by itself but you can also call the calculation by using

    Code:
    [COLOR=#0000ff]double[/COLOR] mySMA = SMA(Close, 20)[0];
    Same goes for your custom coded indicators.

    Comment


      #32
      My question is how to call custom indicator from custom indicator.
      I need to call BBsquese indicator from another indiator.

      SMA,MACD,RSI....built in indicators, I know how to reference thouse, but isn't there a dot notation way to reference any indicator imported to ninjatrader? Something like customindicator1.custind2?

      Comment


        #33
        Just type in your custom indicator name followed by the bracket ' ( ' and then follow the Intellisense guide that pops up on the parameters....

        Comment


          #34
          Thank you Bertrand, that helped a lot.

          I am still not sure how to call indicator plots?

          I have RSI indicator with Bands and I want to call UpperBand and LowerBand from another indicator

          CustomRSI(RSI,14,7).UpperBand

          Intellisense detects this indicator as CustomRSI(Dataseries,period,smooth)

          This would not compile. What am I doing wrong

          Comment


            #35
            It expects a DataSeries input like Close or Input.

            Try this -

            Code:
            CustomRSI(Close, 14, 7).UpperBand
            Does it compile now?

            Comment


              #36
              Silly me...

              Thank you, it woieks!

              Comment


                #37
                Trail Stop Plot

                I can use DrawDot in order to plot my trail stop on my chart and that works just fine. I would like to however have a smooth line through those dots so that it's easier to read. The dots are too large and not very elegant looking in the display. Any help would be appreciated.

                Thanks

                Comment


                  #38
                  mattster,

                  If you want a plot line I suggest using an indicator to actually have a plot. Then just set the plot values for that indicator to the same values as your trailing stop. This would mean copying over the logic used to generate those trailing stop values to the indicator itself.

                  Alternatively you could try concepts shown here to get plotting done from the strategy: http://www.ninjatrader.com/support/f...ead.php?t=6651
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #39
                    I can successfully plot out my stop on my backtest charts but they do not show up on my regular trading charts. Any reason why they might not be displaying?

                    if (Position.MarketPosition == MarketPosition.Long)
                    DrawText("LongStopDot" + CurrentBar,"_", 0, TrailStopLong, Color.Black);
                    else if (Position.MarketPosition == MarketPosition.Short)
                    DrawText("ShortStopDot" + CurrentBar,"_", 0, TrailStopShort, Color.Black);

                    Works great in backtesting.
                    Last edited by mattster; 08-30-2010, 12:52 PM.

                    Comment


                      #40
                      Hello Mattster,

                      Would you please clarify what you mean by regular trading charts?

                      The market position information you're checking will only apply to strategy placed trades. You would have to apply the strategy to a chart and then should see the text whenever the strategy position is long or short.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #41
                        That is correct. I have an active strategy that performs trades throughout the day. Currently short for example, but my ticks are not displaying in the chart that I have open. My entry points are displaying as well as my indicators. The above code is in the OnBarUpdate section.

                        Comment


                          #42
                          Thanks, mattster.

                          Some additional things to check:
                          How you are calculating TrailStopLong and TrailStopShort?
                          Are you applying to a black background chart?
                          What is your CalculateOnBarClose setting?

                          It's working OK here. Check those values with Print() statements or plug in a value based off market prices.

                          Example:
                          if (Position.MarketPosition == MarketPosition.Long)
                          DrawText(
                          "LongStopDot" + CurrentBar,"_", 0, Low[0] - TickSize * 15, Color.Red);


                          If you continue to see issues, post the complete snippet you're using and we can take a look.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #43
                            Plotting Trail Stops

                            I tried using the referenced sample code "SampleStrategyPlot" to plot from within an existing strategy which runs fine. I tried to incorporate the add statement as well as the id variable but I immediately got error codes 1502 and 1503 and it appears that I am trying to mix indicator and strategy classes and it is generating errors. Was it your intent with this sample to allow us to lift code and incorporate it into existing strategies or is this a separate indicator which runs on the same chart as the strategy and somehow magically picks up the traililng stop value from the stategy? If it is the latter, how specifically do I pass that information? If it is the former, why am I getting class conflicts when I try to incorporate the code and how do I fix that?
                            Thanks
                            DaveN

                            Comment


                              #44
                              Dave, how exactly are you coding this out? Can you please post the full code so we can see what's going on?
                              AustinNinjaTrader Customer Service

                              Comment


                                #45
                                Plotting Trail Stops

                                It isn't working yet, but once I have it running I will post the relevant code.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                633 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                364 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                567 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                568 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X