Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ninjatrader candles same direction determine

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

    ninjatrader candles same direction determine

    hi.
    i am writing scripts that shows when 1 and 5 and 15 minute candles are in 1 direction give me trend up and trend down message but
    it seems ninja cant determine 15 min condition.
    when i apply 1 and 5 min condition i can get message but when i apply 15 min condition dont show me message as below pics.
    i use print command for determine .
    its make me happy hear your advise.


    1) in 1 min and 5 min i can see trend message as well as x ,y value in print .
    2) in 15 min cant see any trend message when i apply.also i cant see any x , y value in print.
    main problem exist in 15 minute.
    i check it in playback and live data.


    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.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class TrendTest : Indicator
    {
    double oneMinOpen;
    double oneMinClose;
    double oneMinBid;

    double fiveMinOpen;
    double fiveMinClose;
    double fiveMinBid;

    double fifteenMinOpen;
    double fifteenMinClose;
    double fifteenMinBid;

    int x,y;



    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "TrendTest";
    Calculate = Calculate.OnPriceChange;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(null,BarsPeriodType.Minute,1);
    AddDataSeries(null,BarsPeriodType.Minute,5);
    AddDataSeries(null,BarsPeriodType.Minute,15);


    }
    }

    protected override void OnBarUpdate()
    {

    if (CurrentBars[0] < 30 || CurrentBars[1] < 30 || CurrentBars[2] < 30 )
    return;



    if (BarsInProgress ==1)
    {



    oneMinOpen = Open[0];
    oneMinClose = Close[0];
    oneMinBid = GetCurrentBid();


    }

    if (BarsInProgress ==2)
    {
    fiveMinOpen = Open[0];
    fiveMinClose = Close[0];
    fiveMinBid = GetCurrentBid();


    if (BarsInProgress ==3)
    {

    fifteenMinOpen = Open[0];
    fifteenMinClose = Close[0];
    fifteenMinBid = GetCurrentBid();


    }





    if( (oneMinBid > oneMinOpen ) & (fiveMinBid > fiveMinOpen) & (fifteenMinBid > fifteenMinOpen) )
    {
    x=1;
    Print("x"+x);
    Draw.TextFixed(this, "", "Trend Up ", TextPosition.TopLeft);

    }




    if( (oneMinBid < oneMinOpen ) & (fiveMinBid < fiveMinOpen ) & (fifteenMinBid < fifteenMinOpen ) )
    {
    y=1;
    Print("y:"+y);
    Draw.TextFixed(this, "", "Trend Down ", TextPosition.TopLeft);

    }


    }



    //Add your custom indicator logic here.
    }
    }
    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private TrendTest[] cacheTrendTest;
    public TrendTest TrendTest()
    {
    return TrendTest(Input);
    }

    public TrendTest TrendTest(ISeries<double> input)
    {
    if (cacheTrendTest != null)
    for (int idx = 0; idx < cacheTrendTest.Length; idx++)
    if (cacheTrendTest[idx] != null && cacheTrendTest[idx].EqualsInput(input))
    return cacheTrendTest[idx];
    return CacheIndicator<TrendTest>(new TrendTest(), input, ref cacheTrendTest);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.TrendTest TrendTest()
    {
    return indicator.TrendTest(Input);
    }

    public Indicators.TrendTest TrendTest(ISeries<double> input )
    {
    return indicator.TrendTest(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.TrendTest TrendTest()
    {
    return indicator.TrendTest(Input);
    }

    public Indicators.TrendTest TrendTest(ISeries<double> input )
    {
    return indicator.TrendTest(input);
    }
    }
    }

    #endregion

    ​​
    Attached Files

    #2
    Hello f.saeidi,

    Thanks for your notes.

    You have posted about this same topic in a different forum thread linked below.

    I will be replying to your questions on that forum thread as soon as I am available. Please direct any further questions to the original forum thread and refrain from making multiple threads on the same topic.

    I've an example below that I'm using to access Volumetric Bars based on the following link. It gives me an error. Here's the link: https://forum.ninjatrader.com/forum/ninjatrader-8/indicator-development/106297-can-volumetric-bars-be-added-as-a-second-data-series My example is below: What am I missing in this code to get it
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X