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

Trix

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

    Trix

    I am new to writing the script code. I would like to put buy and sell indicatiors on Plot 1 or the price chart when the moving average crosses the signal line.

    Can anyone get me started.

    #2
    rtj4201,

    Indicators are placed on a certain plot on startup. After that we do not support moving the indicator to a different plot programmatically.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      What I meant was when the Trix Indicator in Plot 2 indicates a buy or sell based on the signal line crossing the trix line, can I ploy an buy or sell arrow on the price chart?

      Comment


        #4
        In your indicator, use DrawArrowUp(). http://www.ninjatrader-support.com/H...awArrowUp.html

        Then be sure to use DrawOnPricePanel = true;
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Can I take the basic indicator and add this script.

          Comment


            #6
            You can modify any indicator you have. If it is a system indicator you will have to rename it to a different name. Right click -> Save As.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              How do I tell it to do this when the TRIX MA line crosses the signal line?



              // Initialize method of a custom indicator
              protected override void Initialize()
              {
              Add(new Plot(Color.Orange, "tag1"));
              DrawOnPricePanel = true; // Draw objects now paint on the indicator panel itself
              // Paints a red down arrow on the current bar 1 tick below the low
              DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);

              Comment


                #8
                rtj4201,

                You should not place such logic in Initialize(). Please move your DrawArrow line of code into the OnBarUpdate() method. From there you can code an if-statement to draw the arrow.

                Untested code.
                Code:
                if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
                     DrawArrowUp(...);
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
                  DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);

                  Comment


                    #10
                    What about the other lines of code?

                    {
                    if (CrossAbove(TRIX(20, 3).Default, TRIX(20, 3).Signal, 1))
                    Add(new Plot(Color.Orange, "tag1"));

                    DrawOnPricePanel = true;
                    DrawArrowUp("tag1", true, 0, Low[0] - TickSize, Color.Red);
                    }

                    Comment


                      #11
                      trix with arrow

                      note: you can safely comment out plot1, plot0 color codes, they don't do anything.
                      Attached Files

                      Comment


                        #12
                        Can you update it so that it gives a down arrow when TRIX crosses below the signal line?

                        Comment


                          #13
                          Originally posted by rtj4201 View Post
                          Can you update it so that it gives a down arrow when TRIX crosses below the signal line?
                          the code for down arrow is already in there


                          // if (CrossBelow(TRIX(period, signalPeriod).Default, 0,1))
                          if (CrossBelow(TRIX(period, signalPeriod).Default, TRIX(period, signalPeriod).Signal, 1))
                          DrawArrowDown("MyArrowDown"+CurrentBar, 0, High[0]+2* TickSize, Color.Orange);

                          // if (CrossAbove(TRIX(period, signalPeriod).Default, 0,1))
                          if (CrossAbove(TRIX(period, signalPeriod).Default, TRIX(period, signalPeriod).Signal, 1))
                          DrawArrowUp("MyArrowUp"+CurrentBar, 0, Low[0] -2* TickSize, Color.Red);

                          Comment


                            #14
                            Thx, it works

                            How would I write BUY or SELL above or below on the price chart above or below the signal?

                            Comment


                              #15
                              rtj4201,

                              You can use DrawText(). http://www.ninjatrader-support.com/H.../DrawText.html
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by firefoxforum12, Yesterday, 08:53 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by kmunroe478, Yesterday, 05:39 PM
                              2 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by kevinenergy, 02-17-2023, 12:42 PM
                              115 responses
                              2,699 views
                              1 like
                              Last Post kevinenergy  
                              Started by prdecast, Today, 06:07 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Christopher_R, Today, 12:29 AM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X