Announcement

Collapse
No announcement yet.

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);
                 
                }

                Comment


                  #9
                  Perfect! Thank you!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  607 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  353 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
                  560 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  561 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X