I'm in the process of writing a fully automated strategy that will do the following:
1. enter limit orders (long/short) for two cars (ES) when my signal criteria is met
2. will cancel the limit orders automatically should price gap 4 ticks away before filling
3. if filled, will set initial stops and two different targets (for scaling out)
4. moves both stops to breakeven at +4 ticks in profit (my first target - using B/E because my targets never sell at first touch)
5. moves stop up on 2nd car (after first is filled) tick by tick, like a trail
6. only trades from 10:15 AM to 3:15 PM (EST)
7. will only enter one trade at a time, even though strat is working on several timeframes
8. will shut down if daily loss is X dollars
9. will email me details (direction, entry price, target/stop fills & prices)
I've already coded and tested most of this but when I went to change market orders to limit, it simply stopped working. I'm sure I'm not the only one who wants to do this so I was wondering if anyone knew of a sort of glorified ATM strat template that has all or most of this laid out, so people can simply enter their own parameters. I've practically tattooed ninja's forum to my brain and have installed more sample strats than I can count. They've helped tremendously but I find them to be incomplete.
Anyway, thanks for reading through both hours of my post
Sir, I cannot argue with you when you use logic against me! Apologies, but my brain is currently fried.
As you can see in the code, I will be adding the 20k and 30k charts to be covered by this strat using BarsInProgress (initial chart will be the 10k). I only have the Add() lines in right now. This is just to make sure it works on one first. You will need BigMike's DoubleMA in order to run. I'll add to my signal later but this will do for now. It usually works fine but sometimes the order self-cancels upon entry, saying I've set my stop as much as nine points in the opposite direction. Be on the lookout and good luck. Any help you can give, especially with respect to the placing of limit orders and the CancelOrder() criteria I described would be of great help.
UPDATE: Fixed a bug - SetStopLoss for shorts were both set to "Short 1a". Changed the second to 1b and it now works as it should. Currently working on changing these from market to limit orders. Will report back. NOTE: You will have to change "a" to "b" on your own right now as I am currently in a state of uncompiled madness...
Last edited by dsraider; February 3rd, 2010 at 07:38 PM.
The following 3 users say Thank You to dsraider for this post:
glad to hear you found the error!
i had a short look into the strat but wasnt able to go through with enaugh concentration/time the last days.
changing STOPS from market to limit orders - i think thats a tricky thing.
its high riks depending on the market you trade -- if it runs through without a fill you get in BIG troubles ! i would not recomment this!
if you wanna go out - go OUT - and dont risk to get no fill!
and i also believe that its not possible at every exchange - it isnt accepted from all exchanges. but i dont have exact infos about this.
maybe someone else can comment this.
Oh, I hear you loud and clear. That's why I'm currently trying to get CancelOrder() to kick in after X number of ticks, should my limit order not fill. I suggested to one of the ninjatrader forum guys (to whom I will soon owe my life) that they create an advanced wizard to deal with things like this. In the meantime, once I get this thing complete (still have a few things to add) I'll post it here as a template so people can just grab it and plug in their signals/parameters.
One thing, though. I'm not changing my stops to limit orders (I'm crazy but I'm not that crazy). I'm changing the entry market orders to limit orders (hence the CancelOrder() language). For the stops, I'm setting an initial stop, then turning it into a trailing stop. That part actually works. I'm not really sure how but I just keep drinking until everything complies
Great idea ! - Thats the way the place works here.
Let me think - once i created smoething like this "cancel if the price runs away without a fill"-stuff ....
i created a double on the Bars high / Low together with the signal-trigger-Bar and then i usesed the cancel-function if the price ran more then this double + X ticks .
but i had to wait for a Barclose to use the bar-high for messuring this.
its not easy to do this intrabar.
so if you where using very small timeframes - that may work for you.
if you use bigger timeframes and the target-vakue is reached long before you have a new barclose - its a probleme - we had a discusion about this somewhere these days.
One solution is to run a multitimeframe-strategy and implant a 1 Range-timeframe.
that gives you the possibility to grab a usable bar-High-value for your messuring-double every new tick higher so to say.
hehe - hope this it understandable - its still early morning here
The following user says Thank You to max-td for this post:
That would help explain my current battle with the intrabar CancelOrder() language. The weird thing is 'Close' actually works perfectly for current price in the trail part so I'm about to test 'if(Close >= Close + X * TickSize)' where Close is the close of the previous bar (my current entry price). Strange, but if it works, it works. The NT Forum guys said it will work. We shall soon see.
Great tip about the range. I NEVER would have thought of that so thanks for the tip.
It's 5:22 AM here so you're the one that needs luck understanding me
In case you (or anyone else) were curious, if(Close >= Close + X * TickSize did NOT work. Nor did anything else I tried today. I hear you on the Range addition but I was hoping to avoid that. So, if you (or anyone else) knows how to cancel an unfilled limit order once it's X number of ticks away intrabar, I will clean your house! Once that's done, I can post this thing.