![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Im am experimenting with crossovers:
if (CrossAbove(EMA(Fast), SMA(Slow),1)) //if the current price is <= crossvalue EnterLong("EMASMA"); elseif (CrossBelow(EMA(Fast), SMA(Slow),1)) //if the current price is >= crossvalue) EnterShort("EMASMA"); I am stuck with the pseudo code in green any ideas greatly appreciated |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You need to determine what you consider is the cross value. Then just compare it to Close[0]. Close[0] on an unclosed bar is the latest price.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
when the crossover occurs - the trade is at market and typically entered above the cross over for a long or below ot for a short - soometimes too much ---
so i want to try to control the entry range - maybe by putting a limit entry on lower/higher as appropiate with a trailing stop --- thats what i am building up to :-)
Last edited by tomleeson; 05-08-2009 at 01:00 PM.
Reason: post analysis of posting !
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
tomleeson,
Submit your limit order at a limit price of Close[0] +/- a few ticks to get you the order in at the cross. You need to do a few ticks because if you are exactly at Close[0] and the price moves away from you you could potentially end up submitting at an invalid price and get your order rejected. Ultimately though slippage is part of electronic trading and you will have to just compensate for it in your system.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Josh - i thouhgt i might be able to do it by getting it on really quick in the same bar - but this was not possible:
if (CrossAbove(EMA(Fast), SMA(Slow),0)) EnterLong("EMASMA"); elseif (CrossBelow(EMA(Fast), SMA(Slow), 0)) EnterShort("EMASMA"); So yes limits would be good - but then they might not be hit - but as you point out you cant get a quote before going to market ans expect it to wait!!!
Last edited by tomleeson; 05-08-2009 at 01:13 PM.
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Right. Your best bet may be to stick with market orders.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
thank you for your help Josh
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Backtest Trading at the Closing Price on the Current Bar | Anagoge | Strategy Analyzer | 13 | 08-25-2010 03:14 AM |
| How to buy at the closing price on current bar? | klchoi123 | Strategy Analyzer | 65 | 08-03-2010 06:49 AM |
| EMA Crossover | Rollins | NinjaScript File Sharing Discussion | 24 | 07-15-2009 10:58 AM |
| SMA crossover using NT script | faithpips | Indicator Development | 6 | 05-01-2009 03:53 PM |
| Multi Time frame Ema Price Crossover??? | linzvb | Strategy Development | 6 | 03-07-2008 07:37 AM |