NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-24-2008, 08:41 AM   #1
linzvb
Junior Member
 
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default Multi Time frame Ema Price Crossover???

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.
linzvb is offline  
Reply With Quote
Old 01-25-2008, 06:53 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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
}
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-25-2008, 08:20 AM   #3
linzvb
Junior Member
 
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Now have I compiled it but I haven't any trade on my backtest?What's wrong..?When I


protected
overridevoid 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.
linzvb is offline  
Reply With Quote
Old 01-25-2008, 08:37 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Here is a link with helpful information that can guide you through debugging.

http://www.ninjatrader-support.com/v...ead.php?t=3418
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-25-2008, 12:24 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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");
            }
        }
    }
}
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-07-2008, 07:31 AM   #6
linzvb
Junior Member
 
Join Date: Jan 2008
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Smile Price Crossover!!

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
linzvb is offline  
Reply With Quote
Old 03-07-2008, 07:37 AM   #7
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

if (CrossAbove(Close, EMA(20)[0] + 20 * TickSize, 1))
// Do something
NinjaTrader_Ray is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 11:29 PM.