idea is if price goes up n breaks 00 or 50 level, it shud buy, and if price goes down and breaks 00 or 50 level it should sell.
#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// System1
/// </summary>
[Description("System1")]
public class S1 : Strategy
{
#region Variables
// Wizard generated variables
private int Lots=1 ; // Default lot sizes
private int Intervals = 50; // Default setting for intervals
// User defined variables (add any user defined variables below)
double Point=0.0001; // Point
double UpperLevel=0, LowerLevel=0, LastLevel=0;
int H=0, L=0;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
//SetProfitTarget(CalculationMode.Ticks, 50);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
Point=TickSize;
if(H==0 && L==0){
L= (int) (GetCurrentBid()/TickSize);
L= L - L%Intervals;
H= L+Intervals;
UpperLevel=H*Point;
LowerLevel=L*Point;
}
if(High[0]>=UpperLevel){
LastLevel=UpperLevel;
Print("Upperlevel broken: "+LastLevel);
//Calculate new levels
UpperLevel=LastLevel+Intervals*Point;
LowerLevel=LastLevel-Intervals*Point;
Print("Requesting BUY at: "+ LastLevel);
EnterLong(Lots,"S1");
}
if(Low[0]<=LowerLevel){
LastLevel=LowerLevel;
Print("Lowerlevel broken: "+ LastLevel);
//Calculate new levels
UpperLevel=LastLevel+Intervals*Point;
LowerLevel=LastLevel-Intervals*Point;
Print("Requesting SELL at: "+ LastLevel);
EnterShort(Lots,"S1");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int lots
{
get { return Lots; }
set { Lots = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int intervals
{
get { return Intervals; }
set { Intervals = Math.Max(1, value); }
}
#endregion
}
}

Comment