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

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
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,403 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    94 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    6 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X