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

dont want arrows,want vertical line on chart

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

    dont want arrows,want vertical line on chart

    I want red lines for red arrows and blue for blue arrows? can any body figure this out?



    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// anaSuperTrend Indicator
    /// </summary>
    [Description("Modified SuperTrend Indicator based on a Moving Median")]
    public class anaSuperTrendsounds : Indicator
    {
    #region Variables
    private int periodMedian = 5; // Default setting for Median Period
    private int periodATR = 21; // Default setting for ATR Period
    private double multiplier = 3; // Default setting for Multiplier
    private bool showArrows = true;
    private bool showStopLine = true;
    private bool paintBars = false;
    private bool currentUpTrend = true;
    private bool priorUpTrend = true;
    private bool gap = false;
    private double newStop = 0;
    private double priorStop = 0;
    private int plot0Width = 2;
    private PlotStyle plot0Style = PlotStyle.Line;
    private DashStyle dash0Style = DashStyle.Dash;
    private Color upColor = Color.Blue;
    private Color downColor = Color.Red;
    private Color neutralColor = Color.Transparent;
    private Color priorColor = Color.Empty;
    private BoolSeries upTrend;
    private MovingMedian1 MM;
    private ATR MAE;
    private int ticksound = 2;
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.Gray, PlotStyle.Line, "StopLine"));
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = true;
    PlotsConfigurable = true;
    upTrend = new BoolSeries(this);
    }

    protected override void OnStartUp()
    {
    Plots[0].Pen.Width = plot0Width;
    Plots[0].PlotStyle = plot0Style;
    Plots[0].Pen.DashStyle = dash0Style;
    gap = (plot0Style == PlotStyle.Line)||(plot0Style == PlotStyle.Square);
    if (ShowStopLine)
    Plots[0].Pen.Color = Color.Gray;
    else
    Plots[0].Pen.Color = Color.Transparent;
    MM = MovingMedian1(Inputs[0], periodMedian);
    MAE = ATR(Inputs[0],periodATR);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    {
    upTrend.Set(true);
    StopLine.Set (Close[0]);
    PlotColors[0][0] = neutralColor;
    return;
    }
    if (FirstTickOfBar)
    {
    priorUpTrend = upTrend[1];
    priorStop = StopLine[1];
    priorColor = PlotColors[0][1];
    }
    if (Close[0] > priorStop)
    {
    upTrend.Set(true);
    newStop = MM[0] - Multiplier * MAE[0];
    currentUpTrend = true;
    if (!priorUpTrend) // trend change up
    StopLine.Set(newStop);
    else
    StopLine.Set(Math.Max(newStop, priorStop));
    }
    else if (Close[0] < priorStop)
    {
    upTrend.Set(false);
    newStop = MM[0]+ Multiplier * MAE[0];
    currentUpTrend = false;
    if (priorUpTrend) // trend change down
    StopLine.Set(newStop);
    else
    StopLine.Set(Math.Min(newStop,priorStop));
    }
    else
    {
    upTrend.Set(priorUpTrend);
    currentUpTrend = priorUpTrend;
    StopLine.Set(priorStop);
    }

    if(PaintBars)
    {
    if (currentUpTrend)
    {
    CandleOutlineColor = upColor;
    if(Open[0] < Close[0] && ChartControl.ChartStyleType == ChartStyleType.CandleStick )
    BarColor = Color.Transparent;
    else
    BarColor = upColor;
    }
    else
    {
    CandleOutlineColor = downColor;
    if(Open[0] < Close[0] && ChartControl.ChartStyleType == ChartStyleType.CandleStick )
    BarColor = Color.Transparent;
    else
    BarColor = downColor;
    }
    }
    if(ShowArrows)
    {
    if(currentUpTrend && !priorUpTrend)
    DrawArrowUp(CurrentBar.ToString(), true, 1, newStop - 8*TickSize, upColor);

    else if(!currentUpTrend && priorUpTrend)
    DrawArrowDown(CurrentBar.ToString(), true, 1, newStop + 8*TickSize, downColor);
    }
    if(ShowStopLine)
    {
    if(currentUpTrend && !priorUpTrend)
    {
    if (gap)
    PlotColors[0][0]= neutralColor;
    else
    PlotColors[0][0] = upColor;
    }
    else if (currentUpTrend)
    PlotColors[0][0] = upColor;
    else if(!currentUpTrend && priorUpTrend)
    {
    if (gap)
    PlotColors[0][0]= neutralColor;
    else
    PlotColors[0][0] = downColor;
    }
    else
    PlotColors[0][0] = downColor;
    }
    ;;


    ;
    //Soundcheck 2 ticks up n down before trend switches

    #2
    Hello,

    Instead using DrawArrow, you can use DrawVerticalLine ():

    DrawVerticalLine(string tag, int barsAgo, Color color, DashStyle dashStyle, int width)
    Code:
                    if(currentUpTrend && !priorUpTrend)
    DrawVerticalLine("Up" + CurrentBar, 0, upColor, DashStyle.Solid, 1)
                    
                    else if(!currentUpTrend && priorUpTrend)
    DrawVerticalLine("Down" + CurrentBar, 0, downColor, DashStyle.Solid, 1)
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kujista, Today, 05:44 AM
    2 responses
    12 views
    0 likes
    Last Post kujista
    by kujista
     
    Started by trilliantrader, Today, 08:16 AM
    0 responses
    3 views
    0 likes
    Last Post trilliantrader  
    Started by AttiM, 02-14-2024, 05:20 PM
    9 responses
    175 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by funk10101, Today, 08:14 AM
    0 responses
    2 views
    0 likes
    Last Post funk10101  
    Started by adeelshahzad, Today, 03:54 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X