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

How to add Up and Down Arrows to boundary's with Renko Blocks using Strategy Builder?

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

    How to add Up and Down Arrows to boundary's with Renko Blocks using Strategy Builder?

    I want to add up or down arrows when price contacts TMA (triangle moving average) bands. Attached is a screen shot of the chart with trend boundary's that I want to have the arrows show up when the Renko blocks touch or pass through the boundary's.


    I watched and followed how this strategy builder video explained to do show up and down arrows.

    https://paul-ninjatrader.tinytake.co...A4M184NTkwOTg3

    My strategy builder code compiles to:

    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class TMABounds : Strategy
    {
    private NinjaTrader.NinjaScript.Indicators.Infinity.TmaBan ds TmaBands1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Triangle Trend Bound Indicator with Arrows Up and Down";
    Name = "TMABounds";
    Calculate = Calculate.OnEachTick;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.ImmediatelySubmit;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.ByStrategyPosition;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    TmaBands1 = TmaBands(Close, 100, 2.618, 20);
    TmaBands1.Plots[0].Brush = Brushes.Sienna;
    TmaBands1.Plots[1].Brush = Brushes.AliceBlue;
    TmaBands1.Plots[2].Brush = Brushes.MediumSeaGreen;
    AddChartIndicator(TmaBands1);
    }
    }

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

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Low[0] + (-4 * TickSize)) <= TmaBands1.LowerBand[0])
    {
    Draw.ArrowUpGreen(this, @"TMABounds Arrow Up Green_1 " + Convert.ToString(CurrentBars[0]) + @" ", true, 0, 0, Brushes.MediumSeaGreen);
    }

    // Set 2
    if ((Close[0] + (4 * TickSize)) >= TmaBands1.UpperBand[0])
    {
    Draw.ArrowDownRed(this, @"TMABounds Arrow Down Red_1 " + Convert.ToString(CurrentBars[0]) + @" ", true, 0, 0, Brushes.Red);
    }

    }
    }
    }

    Attached Files

    #2
    Hi Tonofit, thanks for posting.

    The best way to share code is to Export the strategy and posting the .zip file. Consider using the CrossAbove/CrossBelow conditions to see if the price crosses the TMA value:




    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ageeholdings, Today, 07:43 AM
    0 responses
    10 views
    0 likes
    Last Post ageeholdings  
    Started by pibrew, Today, 06:37 AM
    0 responses
    4 views
    0 likes
    Last Post pibrew
    by pibrew
     
    Started by rbeckmann05, Yesterday, 06:48 PM
    1 response
    14 views
    0 likes
    Last Post bltdavid  
    Started by llanqui, Today, 03:53 AM
    0 responses
    9 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    12 views
    0 likes
    Last Post burtoninlondon  
    Working...
    X