View Full Version : Strange Behaviour with EnterLongLimit and Short Position
simone
11-23-2007, 06:16 AM
Dear,
I'm testing my strategy and I note 2 differents result:
- if I'm Flat and I send a EnterLongLimit the order will be filled
- if I'm Short and send a EnterLongLimit the order will NOT be filled
In EnterLongLimit parameters I specified a MarketValue that is equal to the high value of the bar that I am examining.
Please note that if I send EnterLong the problem doesn't occured.
Ninja Version is 6.5, filltype is liberal.
Thanks
NinjaTrader_Ray
11-23-2007, 07:03 AM
Setting value to the current bar high for sure does not guarantee you a fill on the next bar.
Try sending a value of the limit price of 20,000 and see if it works as you expect.
simone
11-23-2007, 07:36 AM
Sorry,
I don't understand you, I'm testing only 1 day in a backtest. I wuold use enterlonglimit to put my order at a specify marketvalue, but why if the value, that my strategy calculate, is equal at the next high bar the order doesn't go in filled state? In real time I think there isn't this problem.Maybe I'm wrong..
Thank you
NinjaTrader_Ray
11-23-2007, 07:45 AM
When you submit an order on the current closed bar, the high price is historical, its the next bar that determines if an order is filled or not. Thus to ensure a fill, you would need to use the high price of the future bar which of course is not known yet. So if you put in a ridiculous high value, you are betting that the next high is less than this value which would ensure a fill.
simone
11-23-2007, 09:02 AM
Ok,
in fact it's the next bars that reach my marketvalue, so I don't understand because the order is not execute..
Keep in mind that if I'm flat the order is execute, if I'm short no. Code is the same, I comment only //EnterShort
Best
NinjaTrader_Josh
11-23-2007, 07:48 PM
Hi simone,
I can't seem to reproduce the behavior you are describing on my end. Please see the attached test strategy and run it on your end. On my end I am able to enter a short position and then reverse the position with the use of EnterLongLimit.
You will most likely need to debug (http://www.ninjatrader-support.com/vb/showthread.php?t=3418) your code. Please use TraceOrders (http://www.ninjatrader-support.com/vb/showthread.php?t=3627) to figure out what is happening with your specific code.
simone
11-25-2007, 11:55 AM
Dear, to understand my problem I enclose you my strategy example. I note this: when I'm short and would send EnterLongLimit or EnterLongStop, if the market value that I need to use exceeds low or high value of the current bar, both the commands are not processing. But if I simulate the enterShort (so I'm Flat) and send the previous EnterLongLimit and EnterLongStop with the same parameters and at the same time, the orders will be submitted. Where I'm wrong? To replicate my problem please use my strategy and change EnterShort and TicksGap parameters. First step) EnterShort=true and TicksGap=0, at the seven bar we go long, correct? Second step) EnterShort=true and TicksGap>0 (for example 2 or 3), at the seven bar we don't are long, correct? But if you see the output log my strategy send the orders. Third step) change only EnterShort=False, now one of the enters long will be filled, correct? please use EntryHandling=UniqueEntries, min bars required=1 and filltype=liberal before test. Thanks for your support.. Best
NinjaTrader_Josh
11-25-2007, 12:35 PM
Curious as to why you use a -1 index reference in things like Open[-1] in your code.
I will report back after some more testing.
NinjaTrader_Josh
11-25-2007, 09:54 PM
What instrument and time frame are you backtesting this on? I can't replicate the scenarios you are describing.
Again, please use TraceOrders set to true to figure out what exactly your orders are doing. Put this in the Initialize() method.
TraceOrders = true;This will print output to your Output Window with information pertaining to whatever your order is doing. If your order is ignored, there will be information printed about why it is ignored/cancelled.
simone
11-26-2007, 12:49 AM
Hi,
I use index -1 to get the next values.
The Instrument that I'm using is FIBS 12-07 and the time frame is 5.
I will try with TraceOrders = true; and after send you back the report.
Thank you very much
simone
11-26-2007, 06:22 AM
Dear,
I report you trace order output, why Ninja delete my order in step 2 and step 4?
I tried with barsInProgressIndex >0 but method go in error..
Step 1
Correct, Enter Short and EnterLongLimit work
25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
25/01/06 09:10:00 Enter Short
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35825 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35825 SignalName='LongStop' FromEntrySignal=''
25/01/06 09:30:00 Ignored PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35825 SignalName=LongStop' FromEntrySignal='' Reason='Invalid order price, please see log tab'
25/01/06 09:30:00 Enter Long Limit at 35825 Enter Long Stop at 35825
Step 2
Not Correct,Enter Short work but EnterLongLimit doesn't work
25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
25/01/06 09:10:00 Enter Short
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35775 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35875 SignalName='LongStop' FromEntrySignal=''
25/01/06 09:30:00 Enter Long Limit at 35775 Enter Long Stop at 35875
25/01/06 09:35:00 Cancelled expired order: BarsInProgress=0: Order='NT-00001/Back101' Name='Close position' State=Working Instrument='FIBSP 12-06' Action=BuyToCover Limit price=35775 Stop price=0 Quantity=1 Strategy='enterlonglimittest' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='NT-00001' Gtd='01/12/99 00:00:00'
Step 3
Correct, Enter short simulate and EnterLongLimit works
25/01/06 09:10:00 Enter Short
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35775 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35875 SignalName='LongStop' FromEntrySignal=''
25/01/06 09:30:00 Enter Long Limit at 35775 Enter Long Stop at 35875
Step 4
Not Correct, Enter Short work, EnterLongLimi work with strange beaviuor
25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
25/01/06 09:10:00 Enter Short
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35800 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35850 SignalName='LongStop' FromEntrySignal=''
25/01/06 09:30:00 Enter Long Limit at 35800 Enter Long Stop at 35850
25/01/06 09:35:00 Cancelled expired order: BarsInProgress=0: Order='NT-00001/Back101' Name='Close position' State=Working Instrument='FIBSP 12-06' Action=BuyToCover Limit price=35800 Stop price=0 Quantity=1 Strategy='enterlonglimittest' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='NT-00001' Gtd='01/12/99 00:00:00'
I would send you 4 screen shot to understand my problem, do you have an email? (file size is 495 Kb)
Thank you
NinjaTrader_Ray
11-26-2007, 06:57 AM
Hi,
I use index -1 to get the next values.
Please use positive values when accessing values in an array such as Close[1] == close 1 bar ago.
simone
11-27-2007, 09:54 AM
Sorry,
have you any news for me ?
NinjaTrader_Josh
11-27-2007, 01:21 PM
The problem is most likely related to your use of -1 indexing like Ray suggested. Using -1 is effectively submitting an order with a future price that shouldn't be known at the time of order submission.
simone
11-28-2007, 01:11 AM
Ok,
I use index -1 only to get the pricestop or pricelimit.
Using index =0 (for example Close[0]), the problem persist if price exceeds low and high of the currentbar (only if I'm in position).
Marketlimit and marketstop are values larger than current bar.
I think it's a bug. If you would I can send screenshot relative my problem..
Please help me.
Sincerely
NinjaTrader_Josh
11-28-2007, 01:36 AM
Okay how about you send me your simple as possible strategy that demonstrates the issue, database file (My Documents\NinjaTrader 6\db\NinjaTrader.mdb), and tell me the exact settings (including date periods) you are backtesting against. Also let me know of the time I should be looking at during the backtest.
Send them to josh [at] ninjatrader [dot] com. Also, you are on NT6 and not NT6.5 correct?
simone
11-29-2007, 09:49 AM
sorry if I insist
have you any news for me ?
Simone
simone
11-29-2007, 09:53 AM
sorry
I have not seen the answer
NinjaTrader_Ray
11-29-2007, 09:56 AM
Did you follow the instructions and send the info to Josh as requested? If yes, he will get back to you once he has completed his analysis.
NinjaTrader_Josh
11-30-2007, 01:04 AM
simone I did not receive an email with the info. Could you send it again if you already did.
josh [at] ninjatrader [dot] com
simone
11-30-2007, 08:14 AM
Hi Josh,
I'm sending you an email where you will found every informations.
Thank you
Simone
NinjaTrader_Josh
12-01-2007, 12:48 AM
Thank you simone. Will investigate and report back with my findings.