Bogota
Posts: 2 since May 2014
Thanks Given: 1
Thanks Received: 1
|
first of all sorry for my english , its not mi primary lenguaje
its my first post here and im really new in ninjatrader
im trying to write an strategy with this rules
When
ema 14 >ema 9 and close < ema 9
short 100 at market
set stop loss at ema 14
when
ema 14 <ema 9 and close > ema 9
long 100 at market
set stop loss at ema 14
the idea is that on each bar update NT moves automatic the stop loss
i write this but gives me lot of errors
protected override void Initialize()
{
Add(EMA(MediaC));
Add(EMA(MediaL));
SetStopLoss("", CalculationMode.Price, EMA(MediaL), false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (MediaC < MediaL)
{
// Condition set 1
if (EMA(MediaC)[0] < EMA(MediaL)[0]
&& Close[0] < EMA(MediaC)[0])
{
EnterShort(100, "");
}
// Condition set 2
if (EMA(MediaC)[0] > EMA(MediaL)[0]
&& Close[0] > EMA(MediaC)[0])
{
EnterLong(100, "");
}
Thaks for you help and for teachme
|