Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Arrow Automation

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

    Simple Arrow Automation

    Hi,


    Still new to this and gone through some C# online courses so have a basic understanding but still cannot figure out to do something I imagine is very simple.


    The first thing I want to do is to show an arrow if the Candle that has just closed has an open that is 10+ pips higher than the candles close.



    I have done all this through the strategy builder and then looked at the code and not sure why it is not working. Guessing it is something simple and this will help me get to grips with this. Here's my code that is not doing anything on my live charts.



    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Open[1] >= (Close[1] + (10 * (TickSize * 10))) )
    {
    Draw.ArrowUp(this, @"Momentum10PipMove233 Arrow up_1", false, 0, 0, Brushes.Lime);
    }

    }

    #2
    Hello PipTrendz,

    Thanks for your post.

    In the Draw.ArrowUp statement you are specifying the vertical location as 0 (zero) so all of the arrows would be drawn at the price level of 0 (zero). Also, as you are not using a unique "tag name" only the very latest arrow would show.

    I've previously created a short video that demonstrates how to show every arrow and also how to set the "Y" location: https://www.screencast.com/t/Ijoqo7nde5vn

    Comment


      #3
      Thanks for your reply Paul.


      I have gone through the video and made changes to my script as mentioned in the video yet there is still nothing showing on my chart when there should be plenty of arrows.


      Here's my changed code;


      protected override void OnBarUpdate()
      {
      if (BarsInProgress != 0)
      return;

      if (CurrentBars[0] < 1)
      return;

      // Set 1
      if (Open[1] >= (Close[1] + (10 * (TickSize * 10))) )
      {
      Draw.ArrowUp(this, CurrentBars[0].ToString() + @" Arrow up_1", false, 0, (Low[0] + (3 * (TickSize * 10))) , Brushes.Lime);
      }

      }


      How does this look now?

      Comment


        #4
        Hello PipTrendz,

        Thanks for your reply.

        The Y location you are using is Low[0]+(3 *(TickSize * 10) which would place the arrow likely in the candle body itself and could also be hidden behind the candle body. Please click on the candles themself to see the data series selection dots then hold the CTRL and Shift key down whilst moving the mouse wheel back and forth. This will change the "Z-order" of the candles and would expose any draw objects behind them.

        Alternatively, change the Y location to be below the low of the bars by entering a -3 for 3 pips below the low. I've attached an example.
        Attached Files

        Comment


          #5
          Thanks Paul,


          I have changed the arrow location below the candle now (-3) and reloaded the script and it is still not showing anything.


          Is this indicator working on your side? Here's all the script.



          public class Momentum10PipMove233 : Strategy
          {
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Entering on a 10 pip body in the direction of the move (scalping strategy)";
          Name = "Momentum10PipMove233";
          Calculate = Calculate.OnBarClose;
          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.AllEntries;
          IsExitOnSessionCloseStrategy = true;
          ExitOnSessionCloseSeconds = 30;
          IsFillLimitOnTouch = false;
          MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
          OrderFillResolution = OrderFillResolution.Standard;
          Slippage = 0;
          StartBehavior = StartBehavior.WaitUntilFlat;
          TimeInForce = TimeInForce.Gtc;
          TraceOrders = false;
          RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
          StopTargetHandling = StopTargetHandling.PerEntryExecution;
          BarsRequiredToTrade = 10;
          // Disable this property for performance gains in Strategy Analyzer optimizations
          // See the Help Guide for additional information
          IsInstantiatedOnEachOptimizationIteration = true;
          }
          else if (State == State.Configure)
          {
          }
          }

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 1)
          return;

          // Set 1
          if (Open[1] >= (Close[1] + (10 * (TickSize * 10))) )
          {
          Draw.ArrowUp(this, CurrentBars[0].ToString() + @" Arrow up_1", false, 0, (Low[0] + (-3 * (TickSize * 10))) , Brushes.Lime);
          }

          }

          Comment


            #6
            Hello PipTrendz,

            Thanks for your reply.

            In the screenshot I copied your coding in the strategy builder, so yes it is working. I applied it to 15 minute bars because a short bar greater than 10 pips was rare on faster time frames. You might try reducing the 10 pips requirement to see if you can observe any arrows.

            When you apply a strategy you do have to enable it to run by clicking in the "enable" checkbox of the strategy parameters. If not enabled it will not display anything. If the strategy is not enabled or becomes disabled, look at the strategy name on the chart, a disabled strategy will show a (D) proceeding the strategy name, an enabled strategy will simply show the strategy name.
            Last edited by NinjaTrader_PaulH; 05-30-2018, 12:22 PM.

            Comment


              #7
              Got it now thanks!!


              Turns out I had not defined my pips correctly. I am trading the YM and therefore a single unit of movement is a tick and NOT a pip. So it was not picking up on any of the candles I wanted too.



              Thanks a lot for your help, knew it would be something simple!!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              663 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              376 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              110 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              575 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              580 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X