PDA

View Full Version : How to enter 1 Tick above previous bar?


Stevo
01-20-2010, 05:43 PM
Hi Everyone,
This is my first post and would apreciate some guidance as I’m new to this and little confused so please bear with me.

I’m trying to figure out a way of handling entry orders for my trading method within a strategy.

Long example: If conditions are met for an entry.

Enter when price trades 1 Tick above the high of the previous (5 min) bar then place stop under previous swing low.

I first tried this with EnterLongStop() which works if flat, but then discovered it would not reverse if conditions for a Short entry were met due to the SetStopLoss() internal order handling rules.

Next attempt I used EnterLong() within the OnBarUpdate() method but it enters too late at the close of the next bar rather than in real time. But it does reverse!

I ruled out using an ATM Strategy because my trailing Stop is 'price action' based and follows under the swing lows.

Now I’m looking at the OnMarketData() method which looks like it will definitely work on live data but not in backtesting with the Strategy Analyzer (which I need it to do).


I’m now a bit stuck and I’d greatly appreciate any suggestions on what aproach I should use to achieve this functionality and still be able to backtest.

Cheers,
Stevo

dimkdimk
01-21-2010, 04:38 AM
Enter when price trades 1 Tick above the high of the previous (5 min) bar then place stop under previous swing low.



I am not sure if it helps. It might rather dustruct :-)
I suppose, I am doing exactly the same strategy as you do.
I gave up using those internal-ruled orders due to some limitations, rejections and etc. Or, most likely, I was not patient enough to learn how all that "stuff" works.

I decided to use three methods SumbmitOrder, ChangeOrder, CancelOrder. Those are only in NT7 but I have read that other guys have managed to orginise similar behaviour in NT6 ( search forum )
These orders called Unmanaged( look in NT7 fotum there are a few post about them). These methods do not have any limitations, rules, etc. But you have to track your orders yourself.
What I did is, I just stored them in a Dictionary, where key is IOrder returned by these methods, and the value is My class( structure ) that holds extra ( my ) info against the order. So, whenever I get OnOrderUpdate, I just do whatever I need to do and update my data against an order and cancel/create new orders if I need ( I initiate new orders from OnBarUpdate as I am not sure if I can do this from OnOrderUpdate)

Hint: If you want to submit orders intrabars then add for ex. 1min Bars to strategy and do like this:

// Submit Stop order to Open a position
OrderOpen = SubmitOrder( BarInProgEntry,
bLongTrade ? OrderAction.Buy : OrderAction.SellShort,
OrderType.Stop,
FullPoistionSize,
0,
StopPrice,
"",
strTradeName);

Where BarInProgEntry will be 1 ( additional 1 min bars ). In this case in backtest the order will be executed on lower timeframe , hence intrtabar. You can search forum about this stuff as well.

Btw, all info I took from this forum - it is pity that its broken on many small parts so it takes some time to figure out.

This is very simple approach whithout locking, fancy managers, etc. But it works for me, as my main concern is to make money and not programming itself :-) )

NinjaTrader_Bertrand
01-21-2010, 06:28 AM
Stevo, welcome to our forums. You could backtest this with using market orders and submitting those to a finer tick chart for simulating intrabar fills in backtesting -

http://www.ninjatrader-support2.com/vb/showthread.php?t=6652

The ATM's would work for realtime use as well, as you could use AtmChangeStopTarget() for stop adjustments on price action outcomes...however unfortunately not backtestable.

Stevo
01-21-2010, 10:59 AM
Thankyou Dimkdimk for your detailed sugestions. Your unmanaged orders in NT7 look like the way to go for complete control. The example I gave is only part of the story. I want this to trade in 3's by entering in the way described but each 1/3rd has different stop logic and there is a target in there as well, but I haven't got to that bit yet. I'm not on the NT7 beta programme at present but perhapse I should be to avoid wasting time doing this twice. In the mean time I'll try submitting orders to a lower timeframe chart.

Cheers & much appreciated :)
Stevo

Stevo
01-21-2010, 11:58 AM
Hi Bertrand,
Thanks for the welcome & your sugestions.

I'll try submiting orders to a finer tick chart, I'm wondering if there would there be any diference in using a 1 tick range Vs a tick chart in efectiveness or CPU usage? Which would be best?

I was never able to figure out how to set up the ATM to fully implement my stop strategy (explained below) for manual execution so I didn't give it a consideration for this (perhapse I was missing something? please advise if I have).

It would probably involve firing multiple ATM Strats at the same time. The stops all start at the same price but get split up as the trade progresses. All have breakeven function, 1 is OCO'd with an initial target, one trails under PA until hit or reverse & 1's a runner that sits further back until hit or a reversal signal. But not being backtestable is the major drawback.

Ultimately however I look forward to exploring Dimkdimk's sugestion of using unmanaged orders if it can give me complete control and be backtestable, it sounds like the best solution.

How does one get access to NT7 beta? Is it possible at this time?

Cheers,
Stevo

NinjaTrader_Josh
01-21-2010, 01:46 PM
Would imagine both tick charts to be extremely taxing on the system. A range chart would have less bars than a 1-tick chart though so would be less taxing.

You can send a note to sales[at] ninjatrader [dot] com to request to join the beta program.