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 DJ888, 04-16-2024, 06:09 PM
    4 responses
    12 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by terofs, Today, 04:18 PM
    0 responses
    8 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by nandhumca, Today, 03:41 PM
    0 responses
    6 views
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X