![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
|
Can I know please how is possible write a code for 2 time frame and 2 ema???
A red all samples and forum but there isnīt some how this. I like this: if ema-1 on 100min time frame is > then current price +0,25 && ema-2 on day time frame is < then current price - 0,25 do this.... I tried with this sample but isn t working! if EMA(14)[0] > Close[0] && EMA(BarsArray[1], 14)[0] < Close[0] Can you help me please. Thanks. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Code:
if (BarsInProgress == 0)
{
if (EMA(BarsArray[0], 14)[0] > Close[0] + 0.25 && EMA(BarsArray[1], 14)[0] < Close[0] - 0.25)
// Do something
}
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
|
Now have I compiled it but I haven't any trade on my backtest?What's wrong..?When I
protectedoverridevoid OnBarUpdate() { if (CurrentBar < 150) return; /* Checks to see if the day of the week is Monday or Friday. Only allows trading if the day of the week is not Monday or Friday. */ if (Time[0].DayOfWeek != DayOfWeek.Saturday && Time[0].DayOfWeek != DayOfWeek.Sunday) /* Checks to see if the time is during the busier hours (format is HHMMSS or HMMSS). Only allow trading if current time is during a busy period.The timezone used here is (GMT-05:00) EST. */ if ((ToTime(Time[0]) >= 70000 && ToTime(Time[0]) < 190000)) // Short Signal if (BarsInProgress == 0) { if (EMA(BarsArray[0], 60)[0] > Close[0] + 0.25 && EMA(BarsArray[1], 60)[0] < Close[0] - 0.25) EnterShort("EMA Entry1"); } if (BarsInProgress == 0) { if (EMA(BarsArray[0], 60)[0] < Close[0] - 0.25 && EMA(BarsArray[1], 60)[0] > Close[0] + 0.25) EnterLong("EMA Entry1"); } } Thanks. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Here is a link with helpful information that can guide you through debugging.
http://www.ninjatrader-support.com/v...ead.php?t=3418
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
One of the problems I see is your lack of parenthesis.
Code:
protected override void OnBarUpdate()
{
if (CurrentBar < 150)
return;
/* Checks to see if the day of the week is Monday or Friday. Only allows trading
if the day of the week is not Monday or Friday. */
if (Time[0].DayOfWeek != DayOfWeek.Saturday && Time[0].DayOfWeek != DayOfWeek.Sunday)
{
/* Checks to see if the time is during the busier hours (format is HHMMSS or HMMSS).
Only allow trading if current time is during a busy period.The timezone used here
is (GMT-05:00) EST. */
if ((ToTime(Time[0]) >= 70000 && ToTime(Time[0]) < 190000))
{
// Short Signal
if (BarsInProgress == 0)
{
if (EMA(BarsArray[0], 60)[0] > Close[0] + 0.25 && EMA(BarsArray[1], 60)[0] < Close[0] - 0.25)
EnterShort("EMA Entry1");
if (EMA(BarsArray[0], 60)[0] < Close[0] - 0.25 && EMA(BarsArray[1], 60)[0] > Close[0] + 0.25)
EnterLong("EMA Entry1");
}
}
}
}
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
|
Hello support,
can you tell me how is possible have the Price Crossover? Something like this: When current bid,ask (or Close Price etc..) Cross above Ema + 20 ticks. //do something My code for now isnīt working... Problem is that I need when current price cross above Emaīs and not Ema about Ema! Can you help me please? Thanks! VB |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
if (CrossAbove(Close, EMA(20)[0] + 20 * TickSize, 1))
// Do something
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CurrentBar and Multi Time Frame | maxpi | Strategy Development | 7 | 07-31-2009 01:07 PM |
| multi time frame does not take a trade | ceesvh | Strategy Development | 9 | 11-17-2008 05:47 PM |
| Multi Time Frame/Multi Instrument? | GreenTrade | Strategy Development | 3 | 01-14-2008 02:24 PM |
| multi time frame error | woodside | General Programming | 3 | 12-10-2007 11:10 AM |
| Multi-time frame | scjohn | Strategy Development | 1 | 06-06-2007 07:20 PM |