View Full Version : Extreme ^TICK
gary9
11-08-2007, 12:11 PM
HI
I'm getting stopout on extreme ^TICK, (IB NYSE:$TICK-NYSE).
Trading "ER2 Range Bars". Could you show me the Code:
1. Not to take a trade when ^tick is over 1000
2. Not to take a trade when ^tick is below -600
Add("^TICK", PeriodType.Minute, 1); //(Range ?)
&& BarsArray[1] <= 600 ( CS0019 ) Error
Thanks,
NinjaTrader_Ray
11-08-2007, 01:46 PM
In Initialiaze()"
Add("^Tick", PeriodType.Minute, 1);
In OnBarUpdate()
// Processes the primary series you are trading on
if (BarsInProgress == 0)
{
if (Closes[1][0] < 1000 && Closes[1][0] > -600)
// Enter your trade here
}
gary9
11-09-2007, 06:40 AM
Ray
copy and paste, but no trades?
protectedoverridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 8);
SetStopLoss("", CalculationMode.Ticks, 10, false);
Add("^Tick", PeriodType.Minute, 1);
CalculateOnBarClose = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Processes the primary series you are trading on
if (BarsInProgress == 0)
// Condition set 1
if (CrossAbove(CCI(6), CCI(14), 1)
&& Closes[1][0] < 1000 && Closes[1][0] > -600// Tick Extreme
&& CCI(14)[0] > 0
&& CCI(14)[4] > 100)
{
EnterLong(DefaultQuantity, "");
}
NinjaTrader_Ray
11-09-2007, 06:53 AM
You will have to do a bit of detective work and debug your code. Following is a help article on debugging.
http://www.ninjatrader-support.com/vb/showthread.php?t=3418
NinjaTrader_Josh
11-09-2007, 11:42 AM
gary9 you will need { } brackets for your BarsInProgress if statement.
protectedoverridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 8);
SetStopLoss("", CalculationMode.Ticks, 10, false);
Add("^Tick", PeriodType.Minute, 1);
CalculateOnBarClose = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Processes the primary series you are trading on
if (BarsInProgress == 0)
{
// Condition set 1
if (CrossAbove(CCI(6), CCI(14), 1)
&& Closes[1][0] < 1000 && Closes[1][0] > -600// Tick Extreme
&& CCI(14)[0] > 0
&& CCI(14)[4] > 100)
{
EnterLong(DefaultQuantity, "");
}
}