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 02-09-2011, 11:59 AM   #1
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Question EnterLongLimit on MBTrading

I changed my strategy to have EnterLongLimit() instead of LongLimit() as I was displeased on the entry prices I was seeing. It looks like I am not using it correctly, or misunderstanding its use.

if ((iOrderL1 == null || Historical) && iQuantity1 != 0)
iOrderL1 = EnterLongLimit(0, true, iQuantity1, Close[0], sENTRY1L);

Shouldnt the above wait until cancelled for a fill at the Close price from the trigger bar, ie the last bar that closed on BarsArray[0] ??

First attempt today on MBTrading demo gives a fill at same slippage as a strategy running with code that is EnterLong()

Screen attached of the limit order fill

TJ
Attached Images
File Type: jpg limit entry.2011.02.09.13.52.jpg (305.1 KB, 4 views)
Trader.Jon is offline  
Reply With Quote
Old 02-09-2011, 01:10 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi TJ,

Quote:
if ((iOrderL1 == null || Historical) && iQuantity1 != 0)
iOrderL1 = EnterLongLimit(0, true, iQuantity1, Close[0], sENTRY1L);

Shouldnt the above wait until cancelled for a fill at the Close price from the trigger bar, ie the last bar that closed on BarsArray[0] ??
Is this a backtest or a real time fill? If real time, what is your CalculateOnBarClose setting? What is the idea of the OR Historical part of this?
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-09-2011, 01:45 PM   #3
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ryan!

The screens shows the realtime ("First attempt today on MBTrading demo ") test.

COBC=true.

The OR Historical was part of the design from the certified Ninja consultant that helped with the strategy. The same strategy is used for backtesting and realtime. There is no "if (Historical)' type of code in the strategy so I am thinking this "OR" is a different way of doing the same idea.

Thanks,
TJ
Last edited by Trader.Jon; 02-09-2011 at 01:57 PM.
Trader.Jon is offline  
Reply With Quote
Old 02-09-2011, 02:40 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Close[0] should be the close price of the signal bar. Can you send in your log / trace files and we can see exactly how this order was submitted. Use Help > Mail to support feature with Attn:RyanM in subject. Let us know as well the time that these orders were placed.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-09-2011, 03:40 PM   #5
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Email sent
Trader.Jon is offline  
Reply With Quote
Old 02-09-2011, 04:30 PM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Thanks, Jon.

The orders are all submitted at 1.3731

2/9/2011 1:26:50 PM|1|32|Order='6afbc757dffc41f1bac491632b6e548f/Sim101' Name='e1L' New state=PendingSubmit Instrument='$EURUSD' Action=Buy Limit price=1.3731 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

Is this a multiseries script? Possibly getting the Close[0] value from another series? Did you reload historical data at all?

I would monitor this and start printing the Close[0] value so you can verify it's what you expect. Let us know if this is something you can reproduce every time with the strategy.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-09-2011, 05:27 PM   #7
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Question

Ryan,

There was no reloading of historical data unless that happens when you load a strategy on a chart: and there were several bars on the chart prior to the signal being generated as it is set 'wait until flat' to enter a trade.

I will monitor. I am concerned that you think that the Close[0] is from another time frame I am using ... can/should I use Closes[0][0] for the EnterLongLimit() instead ?? Would that resolve the MTF potential issue 100% ??

Please clarify, for the Print of Close ...

if (BarsInProgress == 0)
Print("BA0 Bar closes"+Closes[0][0]); // and so on for each BarsArray?


Thanks,
Jon
Last edited by Trader.Jon; 02-09-2011 at 08:59 PM.
Trader.Jon is offline  
Reply With Quote
Old 02-10-2011, 07:30 AM   #8
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Unhappy Close[0] not so good == run away very quickly

Ryan,

I used two different machines, with a different data source on each (MBTrading and Dukascopy), and modified the strategy to give me more trades, with same strategies on each machine. All testing in SIM from 3am today $EURUSD, default NT Range bars and also Better Renko. The strategy uses 3 Bars Array(0,1,2) for a mix of Range and Better Renko. The LongLimit entry is the same as earlier posted in this thread.

Using just eyeballs, bottom line is that Close[0] as the limit entry price on my MTF strategy has slippage almost 100% of the time (up to 8 ticks!) based on the entry from the close of the trigger bar COBC=true && BarsArray==0. Use of Closes[0][0] as limit price in the same code had minimal if any slippage. This behaviour was seen on both NT Range bars and also the custom Better Renko bars.

If you would like the logs and Print Output let me know asap, but I am guessing you can duplicate similar behaviour.

I suggest changes in the help documentation if you find my observations to be consistent with yours, even if this is 'behavior as expected'.

Regards,
Jon
Last edited by Trader.Jon; 02-10-2011 at 08:46 AM.
Trader.Jon is offline  
Reply With Quote
Old 02-10-2011, 08:34 AM   #9
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Jon,

Yes, multiple time frames could definitely contribute. If you don't exclude other BIP from the calculation then it will use the last updated Close. You may consider capturing the value you want in a variable within BIP 0

if (BarsInProgress == 0)
myLimitPrice = Close[0];

Additional information on this is available at the following link > True Event Driven OnBarUpdate() Method

http://www.ninjatrader.com/support/h...nstruments.htm
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-10-2011, 08:51 AM   #10
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Ryan,

I think I will stay with the Closes[0][0] as the limit price unless you know of a drawback to its use in this scenario. I am trying to keep the code as clean as possible.

Regards,
Jon
Trader.Jon 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
EnterLongLimit and BackTest simone Strategy Development 1 09-09-2010 02:30 PM
EnterLongLimit() ltemme Automated Trading 17 04-15-2010 04:56 PM
EnterLongLimit zooinek Indicator Development 3 05-21-2009 03:58 AM
help on EnterLongLimit toyogo00 Strategy Development 1 07-21-2008 09:46 AM
EnterLongLimit order mike8943 Strategy Development 3 07-04-2008 01:47 PM


All times are GMT -6. The time now is 05:50 AM.