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
Comment