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

Twinline buy/sell arrows

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

    Twinline buy/sell arrows

    Unfortunately I suck at programming, but maybe someone can help me.

    In the HPTTrendfinder indicator arrows indicate when to buy or sell and I am trying to get the same arrows in the Twinline trading system (it's very simple but a good complement to MACD, Stochastic, MFI, Bollinger).

    How it works: Create a SMA of High prices for 1 period and do the same for low prices. You now get a channel around the price. A buy signal is generated when the SMA(low) is greater than the SMA(high) (for some period) and vice versa. But how do I get the arrows? Tried to modify the HPTTrendfinder but got around 17 errors. Any ideas?

    #2
    Hi Precisely, please take a look at the help guide entry for DrawArrowUp(). Inside you'll find the code necessary to draw an arrow. If I understand what you're looking to do correctly, this code should be a good starting point:
    Code:
    if (SMA(Low, 14)[0] > SMA(High, 14)[0]
        DrawArrowUp("up arrow" + CurrentBar, false, 0, SMA(Low, 14)[0], Color.Green);
    That snippet will draw a green up arrow at a y value of the 14 period SMA of lows when the 14 period SMA of lows is greater than the 14 period SMA of highs (which won't be very often because, by definition, lows aren't higher than highs).
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply Austin,

      I will look into the the code you suggested (starting point, I understand), but the comparison is not made between high and lows of the same day/period.

      You make one 1-day SMA of Lows and one 1-day SMA of Highs. For a buy signal to be generated the 1-day SMA low should be > the latest LOW of the 1-day SMA High. You of course need to specify how long back in time it should look for a LOW, but the SMA's are always 1-day SMA's.

      It's easy to understand if you see the graphs.

      Comment


        #4
        Found a picture here http://global.cybersite.se/files/c56...9f692d28e4.jpg

        It's in Swedish, but for interpretation: "saljsignaler" means sell signal and "kopsignaler" means buy signal.

        Comment


          #5
          Does this makes any sense?

          //Buy Signal

          if (SMA(Low,1)> MIN(SMA(High,1))[daysback])
          DrawArrowUp("Twinline Buy" + CurrentBar.ToString(), true, 0, Low[0]-TickSize, Color.Blue);
          }
          {
          //Sell signal

          if (SMA(High,1)< MAX(SMA(Low,1))[daysback])
          DrawArrowUp("Twinline Buy" + CurrentBar.ToString(), true, 0, Low[0]-TickSize, Color.Blue); }
          }

          Comment


            #6
            A 1 period SMA is equivalent to the base series itself so I am not sure what you are looking for. 1 period SMA of low is equivalent to the lows directly. You don't need to use SMA's at all. You can just use Low[0] on a daily chart.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK, this is what I've come up with so far. It works fine, but I don't want it to give buy signals all the time, only when the signal turns from sell to buy and vice versa. How do I do that?

              {
              if (CurrentBar == 0)
              Value.Set(Input[
              0]);
              {
              //Buy Signal
              if (Low[0]> MIN(High, period)[0])
              DrawArrowUp(
              "up arrow" + CurrentBar, false, 0, MIN(High, period)[0], Color.Green);
              }
              {
              //Sell signal
              if (High[0]< MAX(Low, period)[0])
              DrawArrowDown(
              "down arrow" + CurrentBar.ToString(), true, 0, MAX(Low, period)[0]+TickSize, Color.Red);
              }
              }

              It's a very simple but good indicator so those of you how reads this - try it.

              Comment


                #8
                Precisely, is this more what you look for using CrossAbove, Below checks instead of < > -

                Code:
                 
                protected override void OnBarUpdate()
                {
                if (CrossAbove(Low, MIN(High, 10), 1))
                DrawArrowUp("up arrow" + CurrentBar, true, 0, MIN(High, 10)[0], Color.Green); 
                
                if (CrossBelow(High, MAX(Low, 10), 1))
                DrawArrowDown("down arrow" + CurrentBar, true, 0, MAX(Low, 10)[0]+TickSize, Color.Red);
                 
                }
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Perfect! Thank you!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by aa731, Today, 02:54 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post aa731
                  by aa731
                   
                  Started by thanajo, 05-04-2021, 02:11 AM
                  3 responses
                  469 views
                  0 likes
                  Last Post tradingnasdaqprueba  
                  Started by Christopher_R, Today, 12:29 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post Christopher_R  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  166 responses
                  2,237 views
                  0 likes
                  Last Post sidlercom80  
                  Started by thread, Yesterday, 11:58 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post thread
                  by thread
                   
                  Working...
                  X