Finally… How to Get The Size Of Your Account Inside Of A NinjaTrader Strategy

Posted by TraderWerks | Indicators,ninjatrader coding,Strategy,Trading Systems | Tuesday 24 January 2012 1:25 am

FINALLY

I have been using this for a while, since the early NinjaTrader 7 betas, which seems like forever ago  and it has been very useful. Mainly used in risk management, which is usually overlooked by many.

Knowing the account size is very , very helpful for writing code for risk management. Risk management is so important in strategies that most of MY strategies have most of the code in risk management, not entries or exits. Developers really need to spend more time getting the risk management part of the code perfect.

THE OLD WAY

When I USED to do custom programming ( I have no time ) , what I would do would be to keep the starting value of the account and then use the running profit to calculate what the current value of the account was during the trading session.

Painful and convuluted, but it worked. It did have a couple of problems. Well, big problems. The first was that you have to input the starting account value at the start of the session. The second is when you are trading more than one automated system in your account. You are keeping the running total for THAT strategy only and you have no idea of what the other strategies are  doing.

FIXED FRACTIONAL PRICING EXAMPLE

As an example, say you only want to risk 2% of your trade on an a trade. That is fixed fractional risk management which is very popular. You have a $20,000 account,  are trading two strategies and you want to trade one contract per $5,000.

The old way, Say strategy #1 had lost $10,000. Strategy #1 will know about the loss and start trading 2 contracts instead of the previous 4 contracts. Strategy #2 should start to trade 2 contracts BUT it doesn’t know about the loss so it will continue to trade 4 contracts. This was typical using NinjaTrader 6.5, which frankly sucked.

TRADE SIZE

I think the biggest thing is that is helps position sizing and here are some code snippets to help get you started. Tons of people recommend you only risk a certain percentage of capital on each trade and the following code shows you how to do that.. You can use this to set trade size or the amount you risk by setting the stop loss.

Say you want to enter a trade one contract for every $5,000 in cash you have.

position_size = (int) GetAccountValue(AccountItem.CashValue)) / 5000 ;

Or you could calculate the max risk by calculating 2% of your cash.

max_risk = GetAccountValue(AccountItem.CashValue)) * 0.02 ;

Now, please note that futures and equities work differently in the amounts reported.
GET ACCOUNT VALUE

The function that does all the work is the GetAccountValue call. There are a couple of things to notice about this call. The first is that it will return 0 for historical data and that it returns the information on the account that the strategy is running on at the time. The other is that there are more items in Cbi.AccountItem then just the cash value, so you should explore those.

public double GetAccountValue(Cbi.AccountItem accountItem)

PUTTING IT ALL TOGETHER

So let us make a simple example. We will trade 10 contracts when backtesting, one contract per $5,000 running real time or replay.

protected override void OnBarUpdate()
{
    if (Historical)
    {
        contracts_to_trade = 10 ; // trade 10 historically
    }
    else
    {
        if (GetAccountValue(AccountItem.CashValue) > 5000)
        {
            contracts_to_trade = (int) GetAccountValue(AccountItem.CashValue)) / 5000 ;
        }
    }
}


GetAccountValue() doesn’t require very much computing power so you can call it fairly often.

NOTE

The ability  or inability for these functions to work depend on the information provided by the broker to NinjaTrader. So you should test using your brokers connection.

If you have any questions, just leave a comment.


Photo Curtesy John Althouse Cohen


PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email

 


Good to see you! If you are new here, you can subscribe to the RSS feed for updates


Writing Passive Relative Orders in NinjaTrader Strategies ( PASSV REL )

Posted by TraderWerks | Indicators | Tuesday 10 January 2012 9:45 pm

INTERACTIVE BROKERS PASS REL ORDERS

I was chatting with a friend that was trying to write passive relative orders in Ninja Trader that he had used in Interactive Brokers TWS.

Since you know I have no love for interactive brokers, I thought I would give him a hand.Besides, I have not written a coding post for the blog in a while.

 

If you want to find out how I feel about Interactive Brokers, just use the search bar over there.

Regardless, Interactive Brokers ( From now on, I will just type IB instead of Interactive Brokers because it is getting way to tiring to write the whole thing ) has a pretty good selection of orders, one of them being a Passive relative order (PASSV REL )

WHAT IS A PASSIVE RELATIVE ORDER ?

Lets start by looking at the IB website.

Passive Relative orders provide a means for traders to seek a less aggressive price than the National Best Bid and Offer (NBBO) while keeping the order pegged to the best bid (for a buy) or ask (for a sell). The  order price is automatically adjusted as the markets move to keep the order less aggressive

 

What is is in reality is an attempt to get a better price. Putting in an order away from the market hoping the market will come back and get you into the trade at a better price.

Stocks, futures and options ( and other things , but you get the idea) move up and down all the time. A passive relative order is an order that sits relative to the bid / ask and waits for the price to come back and get filled.

The difference between this and a limit order is that limit price will move relative to the bid/ask price. So here is an example of this type of order.

 

I won’t go into detail here, but there is a really good explanation on the IB website.

THE CODE

This PSEUDO code below is for Ninjatrader strategies. I think the closest you have in the ATM strategies is the ATM strategy. The code is a little advanced so you will have to bear with me on this one. If you are just a beginner at Ninja script, I would leave  this type of programming alone.

I went with PSEUDO code because if you are advanced enough write this, you probably would not have a problem writing the C# code yourself. I was going to release code, but I thought that would be to confusing. If there is enough interest, I will release it. So leave a comment and if enough people want it I will release the NinjaTrader code.

 

The first thing you will need is the order object and the bid / ask prices.

double offset_price ;
double max_price ;
bool entry_direction ;
double current_limit_price ;

...

We need to keep the entry direction since passive relative orders act with the direction.

The next part is in OnOrderUpdate(), remember to check for the IOrder.Token.

OnOrderUpdate()
{
  // wait until order comes back confirmed,and store the value.
if ( order completed ) current_limit_price = order price 

}
OnMarketData {

    ...
    double mid_point = ( GetCurrentBid() + GetCurrentAsk() ) / 2 ;
  // if the price is at max price do not move
  if ( current_limit_price gt max_price ) return
   // now if price is to far away, move the limit order
   if ( difference (mid_price , current_limit_price ) > offset_price )
      cancel order
     enter_new_order(mid_price , current_limit_price)
    ...
}

Most , well all , of the heavy lifting will be done in the OnMarketData and OnOrderUpdate. You cannot do this using on bar update.
 
I have just touched on the subject, if you would like me to write more , leave a comment so I know other people are interested.
 

A LITTLE WARNING


Programming this stuff is considered advanced programming and is for experienced programmers. Don’t blame me if something goes wrong.

Using this type of order can and will generate a lot of cancel order messages as the limit order is moved.

For futures there are message limits that can lead to a fine and in options there are usually cancel fees from the exchange. Of course your broker may add something on also, so you mileage will vary.

And finally, using a lot of cancel and replace orders , you may run into ‘in-flight’ order problems. Which are usually not nice.


Photo by szeke



PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email


Good to see you! If you are new here, you can subscribe to the RSS feed for updates

A Talk with Big Mike from Big Mike’s Forum

Posted by TraderWerks | Indicators,Interviews,Trading Systems | Friday 27 May 2011 10:22 pm


BIG MIKE’S TRADING FORUM


Big Mike’s Trading Forum is a great place to hang out and discuss trading. I have been following Big Mike since he was on the Ninja forum as ctrlbrk. He has always been a very helpful guy. He was nice enough to answer a few of my questions as his forum is coming up on his second anniversary even with a broken hand.

This is a great interview and well worth a read. Interview posts are not very popular on my blog, but they are much more informative and useful if you want to make a living from trading , it would be good to listen to those who have been around for a while like Big Mike.

 

So after reading this post, head on over to Big Mike Trading, a great forum for traders and some of the things he has planned for the second anniversary.


  • Memorial Day charity drive: All Elite subscriptions get donated to charity
  • Battle of the Bots: June Winner gets Algo Trading book from Amazon
  • Teaching contest: Win an iPad 2 for the best thread teaching a methodology (follow-up to our iPad 2 journal contest)
  • Velocity Futures Webinar: Giving away two cent commissions for an entire month to two people
  • Suri Duddella Webinar: Chart pattern expert, giving away 10 autographed copies of his book
  • MultiCharts Webinar: Platform overview, new features, giving away two lifetime licenses and two sets of two hours each programming time for custom indicators or strategies
  • NinjaTrader Webinar: Platform overview, new features, giving away two round trip tickets from anywhere in the world to Las Vegas for November 2011 Trade Expo, plus one two year subscription to NT
  • Al Brooks Webinar: New price action books, price action trading: giving away 10 autographed copies of his book

AND NOW THE INTERVIEW

[1] One of my big things is journaling. I even print out my journals at the end of the month. When I go back over them months later I learn so much about my trading. I know you are a big fan of journals also. My question is, why do you think it is so hard from some people to do journals?

“Journals are probably the single best tool a trader can have.  Yet most traders throw it out the window and think they don’t need a journal.  Well, most traders fail.  So do the math…  I think people come up with a list of excuses that they don’t need to journal, but the single biggest one can probably be simplified into lack of determination to see it through.  Another common one is simply the “lack of time” excuse.  To me this says the trader is overtrading and it would take them hours to journal about all the trades.

Individual traders are not computers.  Let the computers do high frequency trading.  You should focus on just a small number of setups each day, maybe 3-5 trades at most.  Anyone should be able to write down why they entered and exited a trade three times a day, no excuses.”

[2] Somewhat related to the previous question, in that you have to be honest with yourself to improve. Why do you think people are not honest with them selves in their trading. Almost as if they see what they want to see.

“It’s not that people intentionally deceive themselves.  I don’t believe that.  What I’ve found through my own experiences and through the forum is that traders get caught up in something and can’t see the forest for the trees.  I refer to it as the black hole phenomenon, where the trader gets sucked into this vicious cycle of repeating the same mistakes over and over.  But the trader can’t escape.  In order to deal with this, the mind plays tricks and invents all sorts of reasons that a trade failed or that the trader lost money.

I’ve got news for you, if you don’t accept full and complete responsibility for every action, beginning to end, having to do with your trading – you will never succeed.  Don’t blame your computer if it is slow.  Don’t blame your internet connection for dropping out.  Don’t blame your platform for crashing.  Don’t blame Goldman Sachs for running your stop.  And worst of all, don’t play the “if only” game with your indicators.  If only you had… <insert 42 excuses here>.  It’s all you.  Own it.  Take responsibility.  If your computer sucks, your internet connection is flaky, and  your platform crashes routinely, then you shouldn’t be trading until you resolve all of those issues.

Once a trader finally comes to terms with the fact they are solely responsible for their own trading success or failure, it can be an eye-opening experience.  On the one hand, you can finally move past all the junk that gets in the way psychologically holding you back, and face it head on and deal with it.  But on the other hand, you finally realize you have only yourself to blame.  It’s crunch time.”

[3] We all start out somewhere trying to be full time traders. Do you have any advice for someone who is marginally profitable part time to make the jump to full time ?

“If you are marginally profitable, my first question is over what time period and how many trades?  I would be cautious if the term is less than 1 year and the frequency of trades is less than say 500.  Don’t get cocky and think because you had two good trades in a row that you’ve got this trading thing licked.  Trading success is incremental.  There are many things you must master, all individually, in order to finally put all the pieces together.  You can’t skip over the hard parts, there are no short cuts.  There is no indicator or trading system to download that will make you money.

My advice begins with “congratulations!”.  Even marginally profitable is considered a success in terms of the larger group of traders.  Build on it, slowly.  One of the most common mistakes traders make is allowing their ego of always wanting to be right to get in the way of a trade decision.  That often leads to giving back days, weeks, months or even years worth of profit in just a handful of terribly executed trades.  So go slow, don’t get cocky, and make sure you have some meaningful analytics in place to measure your success.”

[4] I have been trading the same basic system for the  last few years. It has evolved over time, but it is basically the same. I run into others who constantly want to radically change their system even when they have a perfectly workably system, one bad day of trading and they throw the system  out and start their search again? What are your thoughts?

“Congrats!  That’s awesome that you’ve been trading the same basic system for this length of time.  I constantly tell people to stop changing everything.  People rush to change indicators, tweak settings, or download the newest craze system in order to solve an underlying problem with their own trading psychology.  They want more filters, they want to stay out of chop.  Basically, they want the holy grail.

If you have been trading for 3 years but you’ve changed your method every few weeks, then you don’t have three years of experience but rather only a few weeks experience.  I strongly believe that success is determined by your ability to read the market, and not by your ability to follow a blue-to-red trading system or indicator.  You don’t stand a chance of properly reading the market if you are constantly changing your charts and indicators.”

[5] In trading, I have found that best advice I have ever received has been free or inexpensive. I usually steer people who ask me questions to Reminiscences of a Stock Operator ( can be found free ) , the CME website, and Al Brooks book ( Soon to be in English ). Besides Big Mike Trading, of course , where else would you direct others ?

“I prefer reading Trading Psychology books.  Brett Steenbarger has several absolutely excellent books, and a blog online that is filled to the brim of real-world advice.  I don’t read books that describe methodologies very often.  If the book has lots of pictures of charts, then it is really of no interest to me.  Sure, I’m always eager to learn new things, but I want to incorporate it into my existing trading system and am not eager to make any kind of departure from what is working for me.

As for online resources, of course I think BMT is the place to be.  I don’t frequent any other trading related websites anymore since BMT has taken off.”

[6] How do you deal with the boredom of trading? That is sitting on your hands and waiting for a great trade. Is it something that came with experience for you?

“If trading is exciting, your probably losing money.  I don’t treat trading like gambling.  I go to Vegas to gamble, which means to have fun.  I trade in order to make a living.  I usually trade for about 2-3 hours per day.  During this time, I turn off my phone, TV, and I don’t browse the web.  I am looking solely at charts on all of my monitors and I work to get in rhythm with the market.

With my particular methodology, I know where I want to enter and exit a trade ahead of time.  So I place limit orders and don’t have to watch the market tick by tick in order to press the button to get into a trade.  I would suggest a similar approach to others, as watching every tick will just lead to over trading and second guessing of your original analysis.

That said, a huge number of traders have a problem over trading.  My suggestion to them is to make a promise to yourself that you will take only 3 trades a day, period.  So help me, if you take 4 trades….  I find that knowing this number ahead of time really helps to focus traders.  Of course if you make this promise with yourself, your best bet is to post about it in your journal on BMT so you get the extra accountability you need.  The mind is a powerful tool, be sure you are using it to your advantage :)

[7] Finishing up, if you could give one and only one piece of advice to a trader, what would it be ?

“Be realistic with your expectations.  Too often, traders come into this business and think they can turn their $500 forex account into $5,000, or they can turn their $20,000 futures account into a steady $75,000/yr income.  You cannot.  Those kinds of returns are outlandish.  Just because some guy on a website selling you his secret method says you can do it doesn’t mean you actually can.  Be realistic.  Realistically speaking, you will probably spend $20,000 to $50,000 the first two years you trade.  I say “spend”, not “lose”, because I look at this period as your tuition and its an educational expense.  Hopefully your third year you can earn a 10-20% return or so.  By your fifth year, maybe you can get to your $75,000/yr income figure with a modestly sized account.  A common number thrown around is 10,000 hours – you need 10,000 hours before you start to “get it”.

Expanding on the above – make sure you treat trading as a business.  If you are serious about being a full-time trader, then act like it.  This means no interruptions while you are working.  No wife and kids coming into your office every hour.  No surfing the web, watching TV, sleeping in, staying up late, etc.  If you don’t respect yourself enough to treat your trading business seriously, then you won’t succeed.  After you “make it” in trading, you’ll find your life will open up and you can do the things you’ve dreamed about without them interfering with your work, because you’ll likely only be working 2-3 hours a day.  But during your tuition period, you can expect to work 12 hour days routinely.

TW, it’s been a pleasure answering your questions today.  I look forward to seeing you, and your readers, on BMT!

Big Mike”

 

 

Good to see you! If you are new here, you can subscribe to the RSS feed for updates

Trading Ninja Trader With TT ( Trading Technologies ) May Kill Your Account

Posted by TraderWerks | Indicators | Wednesday 18 May 2011 9:50 pm

DO NOT HOLD OVERNIGHT

I just wanted to get that out there in the beginning. Do not hold overnight positions using Ninja, period. Your PnL and positions will get totally out of whack when doing overnights and it is not as all fun as a lot of not nice things can happen in your account. I will describe it as “Evil” as a blanket term for bad things that can happen to your account.

I have NEVER once held futures position on purpose overnight. Note that I have said on purpose. I have woken up to start trading and noticed I had a position on in the per-market, that should not have been. I no longer had a profit or stop loss orders in the market so I was trading with out any protection. If a black swan had happened overnight, I would have been … messed up. That is a feeling I never want to have again which is why I check my positions everyday I trade.

WHAT BROKERS USE TRADING TECHNOLOGIES

This is overlooked a lot because most people associate NinjaTrader with Zen-Fire. In the beginning that was the big marketing push. NinjaTrader can connect to several different broker technologies, like IB ( Interactive Brokers ) and others.

Some brokers like Deep Discount Trading, Velocity, Advantage offer NinjaTrader but with Trading Technologies instead of Zenfire. By using Trading Technologies FIX connection, they can lower their commissions and a lot of traders won’t notice the difference anyway.

If you do hold positions overnight and have a problem You won’t get much sympathy from Ninjatrader support. Every broker will handle this differently and I have even heard that Ninja/TT will ‘act’ differently depending on the TT infrastructure that the broker has in his / her office.

We advise you NOT to carry positions overnight (between sessions) since NinjaTrader cannot accurately report your position which can adversely affect your account. – Ninjatrader.com

That is from NinjaTrader’s connection guide. It does not say what will happen, we just have to assume it is something evil.

WHAT HAPPENS AT THE END OF THE DAY?

There are more problems than mark to market trading with TT, but here is a small explanation from one of the Ninjatrader support staff on PnL calculation that I waned to include here.

When a product closes for the day and goes to a pre-open state, the broker will carry the position forward at the settlement price (*). When the futures contact closes and moves from a ‘closed’ to ‘pre-open’ a few minutes later, the open PnL is booked and set to ’0′. The new average price is then set to the price the market is trading at the open. This is technically correct and expected for all futures contracts. This is referred to as ‘Marked-to-Market’ and is how all futures contracts are handled.

*: In electronic futures, the broker will use the last traded price since the settlement is actually done in the pit and the broker will have no access to that data until the end of the day.

Also, if you have any GTC orders that are still open at the end of the day, they will also be re-opened.

CHECK YOUR ACCOUNT AT THE END OF THE DAY

At the end of the trading day, you should check that you do not have any un expected orders or positions in the market if you are a day trader. Most of the time it will be empty as it should be, but the one time you catch a mistake or a problem , it will be worth it. The thing you want to watch for is GTC orders that stay on your book. usually these are entry orders that may have been laying around like little landmines.

Most clearing firms have a web portal that lets you check your positions and orders. This is a great complement to Ninja trader because even if it does not show up in you account size or position, it will show up on your clearing firms system.

Remember, GTC orders are evil for Day Traders.


PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email


Photo Courtesy x-ra delta one

Never Trade With Ninja Trader On A Laptop Without This Free Indicator

Posted by TraderWerks | Indicators | Wednesday 12 January 2011 4:52 am

HAPPY HOLIDAYS

First I want to say ,Happy Holidays Christmas , Hanukkah , Kwanzaa, American Samoa Day. The holidays see a lot of us traveling on the road, including me.

This holiday I did something crazy in trading Christmas week. I did well the first part of the week, the lously the last day. I broke even so I cannot complain.

This indicator came about becuase I was constantly getting distracted AND I was trading on a laptop. When you are using electronics now , it seems like power outlets are never enough. I was not the only one using a laptop. Or iphone. Or Blackberry. Or iPad or any number of devices that needed to be plugged in on the power strip.

ANY THING THAT CAN GO WRONG, WILL GO WRONG

Trading from a laptop has a different set of problems than trading from a desktop computer. You are always attached to the power brick. For example, my laptop was unplugged once while I was trading. I was sitting in front the computer so it wasn’t a problem , just annoying.

This can be a big problem if your computer shuts down while you are in a trade. Bracket orders ( what most of us use with a profit target and stop loss ) stay on your trading platform. In this case my laptop. So if my laptop’s battery failed , ran out, whatever then I will have big problems in that OCO orders would be in the market.

You can check out this blog post that explains it a little bit better CLICK EL HERE

THE BATTERY LEVEL INDICATOR

So I wrote this battery level indicator for just this situation. The indicator shows the percentage of power remaining in your laptop’s battery.

Download NinjaTrader 7 Battery Level Indicator (FREE) here

It is very straight forward to use. you can use it in strategies or on the chart.

Parameters:

  • Alert Level – This is the level where the indicator will alerting you
  • Alerts On / Off - Turn on or off audio alerts.
  • Show Battery Indication – This displays when the laptop is running on battery power

USING WITH STRATEGIES

Ok, this post is getting long so I will split it into two sections. The next post will show how to set your strategies so that if you are trading on a laptop and you laptop is about to fail, the strategies will close all positions and shut down.


PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email



Photo curtesy pedrosimoes7

Traders Guide To Ninja Trader Monte Carlo Analysis

Posted by TraderWerks | Free Indicators,Free Software,Indicators,Strategy | Monday 27 December 2010 6:24 am

Well since NinjaTrader 7 will probably be released in 2008 2009 2010 is released , I wanted to look one of the new features.

One of the most exciting is NinjaTrader 7 has a built in Monte Carlo analysis section. I should say cool and useful instead of exciting.

Before NinjaTrader 7 , if I wanted to run a Monte Carlo analysis , I would have to do it myself from a trade file. Pretty annoying and time consuming.

OK , WHAT IS MONTE CARLO ANALYSIS ?

There is no single Monte Carlo method; instead, the term describes a lot of approaches.

Monte Carlo simulation uses a random sampling of probability distribution as model inputs to produce hundreds or thousands of possible outcomes  providing probabilities of different outcomes occurring.

A Monte Carlo analysis looks at your trades, puts them in a random order over and over, to give you and idea of what your trading should look like over the long term. Note that I said ‘give you an idea‘. Not that anything is certain especially in trading.

OK SO WHAT DOES THAT MEAN FOR A TRADER

Using Monte Carlo analysis means given what we know about a trading systems results, we can try to get a best guess as to how a trading system would perform in the future.

Monte Carlo Simulation will randomize your trade results over and over again in multiple simulations to provide you with a normal distribution of simulation performance.

So say you have been trading for a while and you have 100 trades in NinjaTrader. What Monte Carlo will do , is randomize all your trades and give you a percentage of whatever you are measuring above or below a value.

It is a big ‘what if’ game. Looking back at the example, if we have a 100 trades and we do 100 trials , we will have information such as ’95% of the time, we made X dollars’ and things like that. Perhaps some examples would help.

EXAMPLES

Now all these examples I am talking in generalities. This is a random distribution which in itself is , well, random. Now to prevent me from having to write “the results are based on a random distribution of your result set and should only be viewed as educational in nature” everywhere , just add it to the end of every sentence. Thank you for your support.


    Cumulative Profit


Click For Larger Image

So for this particular system, we are looking at the amount profitable. The bottom is a percentage of the trades. If you click on the image, you will see a highlighted area at 5% / $35.3. What that means is that 5% of the time, the profit will be less than $35. Or 95% of the time the profit will probably be greater than $35.


Click For Larger Image

This chart is the maximum consecutive losses.  Here we can say that 70% of the time, we only have one loss in a row.


Click For Larger Image

Finally, Drawdown. Looking at this chart, well over 90% of the ‘tests’ would have less that a $200 drawdown. Now with that information, it is much easier to detect fraud.


PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email


Photo by of http://www.flickr.com/photos/kjunstorm/

End Of The Line For Ninja Trader 6.5

Posted by TraderWerks | Indicators | Tuesday 30 November 2010 1:14 pm

NINJA TRADER 7 FINALLY !

Well it is about time. Ninja Trader 7 is about to be released, and it is time to put NinjaTrader 6.5 to rest. I have it on good authority that NinjaTrader 7 will be released sooner than later, as in the next few weeks.

I have not written a NinjaTrader 6.5 indicator in a long time. I switched over to trading NinjaTrader 7 live in the fall of 2009 ( Yes, I was stupid brave at the time and I traded my actual futures account ) to make sure I was able to keep up with the changes in NT7.

It is the end of November 2010 and NinjaTrader 7 will be released real soon now, soI am retiring Ninja 6.5 and will no longer be able to make NinjaTrader 6.5 indicators.

I haven’t traded with NinjaTrader 6.5 in a long while and I cannot see any reason I would be in the future and since I do not want to keep it around taking up disk space, in the Recycle Bin it goes.

WHAT ABOUT MY OLD 6.5 INDICATORS?

What about my old indicators that I got from TraderWerks ? Just drop me a line at traderwerks@gmail.com and tell me what indicator you have and I will replace it with a brand spanking new NinjaTrader 7 indicator. You can send me an email at the usual email address.

This is a FREE replacement/upgrade for any indicators that were free or paid. For licensed indicators, send your machine key if possible.

TIME TO CONVERT OVER FOR THE REST OF YOU

So for those of you who haven’t converted over yet, it is a good time to download the NinjaTrader 7 beta and get your code compiling. There are a few differences in the indicators that you will have to change.

I wrote about converting my indicators over to NinjaTrader 7 in this post.Taking The Ninja Trader 7 Beta Out For A Spin Another resource you may want to take a look at whilst you are converting over is the Ninja Trader list of code breaking changes which is on the NinjaTrader support site.

WHY YES, I DO HAVE A NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email

Photo By ** Maurice **

A Great Trading Book You Probably Have Never Heard About.

Posted by TraderWerks | Book Review,Indicators | Friday 29 October 2010 6:20 am

( For those of you who do not want to read the whole blog post, you can download the book here FOR FREE “Principals and Psychology of Day Trading” no signup or anything )

YOU CAN ALWAYS LEARN SOMETHING AND SOME OF THE BEST THINGS ARE FREE

I was on a board discussing account minimums and people trading small accounts. I think a lot of people have really bad information on trading with a small account. Trading with a small account means trading with ‘scared money’ until you figure out what you are doing. All of us started out as ‘newbies’ and learned along the way.

There are some good educators and mentors out there , but there are more scam artists BY FAR out there preying on ‘newbies’ promising a lot with a small account.

I know one ‘educator’ that does not trade actual money ( I am not saying the educators name, but you know who you are ) says things like ‘We made $900 and only needed $1,500 of margin’. Yeah, right. A three contract trade needs more like $6,000 to $15,000 and that is still pushing it.

Anyway, my thoughts can be summarized as :

I guess what I am saying is being under capitalized is bad, not knowing how to trade is worse.

It is quite true. If you are trading a small account , you probably will not make enough to live on and you really , really , really need to understand risk management ,the psychology of trading and have realistic expectations.

Anyway, it lead me to think that there are some free resources that can help others learn how to trade without have to send money to an ‘educator’. Not that all educators are bad, but there are things that can help traders in general. There is also free education on trading on most of the exchanges websites that will get you started.

I have learned a lot about trading from free or close to free sources. From the exchanges, from other traders and by reading a lot. ( I have more formal training in finance, but that really doesn’t apply to trading. )  So here are a couple of free ebooks for everyone and especially for those starting out with small accounts.

A GREAT BOOK YOU HAVE PROBABLY NEVER HEARD ABOUT

Well, this guy gives the book away on his website. “Principals and Psychology of Day Trading” no signup or anything. No need to give your email address or anything else.

I don’t have any connection with George or his site, I just enjoyed his book. It does not read like a traditional manual, but more like a series of lessons learned via experience about day trading in the pit and on the screen.

Now, I don’t agree with every thing he writes, but I do agree with a lot of it. His methods are pretty old school, which is to be expected coming from a person who started trading well before electronic trading was ever a factor.

It looks like the guy started to write a book to sell , but in the end just gave it a away. Who knows? Any way , it is free so go grab a copy.

Now on to the second free book…

REMINISCENCES OF A STOCK OPERATOR

I always keep reading when I have the time ( which is really rare ) and I encourage everyone else to do so also. I have read Reminiscences of a Stock Operator a few times and every time I find myself learning something.

I must admit, the first time I did not read the book all the way through a few years ago. But every time after that I learned something new and read further. Did I mention that the book is in the public domain now? So it is free.

    You can always learn something new and some of the best things are free.

PIMPING MY NEWSLETTER

I don’t post often, but I do have a mailing list you can subscribe to in the meantime. I usually write about Ninjatrader programming, but other trading topics as well. Subscribe to TraderWerks Blog by Email

Photo By John Picken It is a picture of three Chicago exchanges all in one picture.

Dude, Where’s My Order ? (Where Is My Order When NinjaTrader Crashes )

Posted by TraderWerks | Indicators | Thursday 5 August 2010 2:52 am

Dude, Where’s My Order

I thought Dude, Where’s My Car was a great mindless comedy. No need to engage any brain cells on that one. Ashton Kutcher who starred in the movie went on to make lots more mindless comedy. I saw a post on the “Interwebs” that made me think of that movie.

I saw this post on ET ( EliteTrader )

I long 1 ES contract at 1109.50, put stop-loss at 1107.25 and target at 1111.25. I was stopped out at 1107.25 ( 2.25 points ), but my target was later executed at 1111.50 ( another loss of 0.25 point ). The total loss of 2.50 points ( $125.00 ) and I was charged $9.60 which was for 2 contracts.

Both AMP Futures and Dorman Trading did not give me explanation after 1 week.

Don’t know what went wrong with the trade. The amount of money is small in this case, do I just accept it and move on?

I noticed, because I trade with Dorman/AMP. I have never had anything like that happen to me. Strange I thought.

Later, the same person posted…

I usually set the stop-loss and profit target through the NinjaTrader ATM strategy and the execution is without problem. That means if either the target or stop-loss is hit, the other will automatically being cancelled.

But in this case, my target price ( 1111.25 ) turned into another short order, and amazingly being stopped out just 0.25 point away ( 1111.50 ). Who determined that exit point for me?

I turned off my trading platform before the target / stop-loss was hit, so got no idea what actually happened to my pending orders. I usually do so without any problem.

I removed the names to protect the innocent. But is is a valid question, with an embarrassing answer.

OCO ORDERS.

A little background is in order. One Cancels the Other is abbreviated as OCO. Traders use OCO orders in NinjaTrader a lot without even knowing it. Whenever you use the Ninja ATM ( Advanced Trade Management ) which sets a stop loss and a profit target, THAT is an OCO order.

Ninja places TWO orders in the market after you enter the trade. One is the profit target order and the other is a stop loss. Say you are long, the profit target is a short limit order above the market and a short stop market order for the stop loss order.

For most brokers, when you enter the order, the two orders ( profit & stop loss ) are sent to the broker who sends them to the exchange and they then sit on the exchange book. The exchange knows nothing about your OCO order, and neither do most borkers. Just that there are two orders there, it is up to the trader ( on Ninja ) to take care of closing things out or your broker if your broker supports that functionality.

WHAT HAPPENED

What happened was exactly what should have happened. S/He was long a contract with two orders on the exchange book, the profit target and the stop loss. The Trader closed Ninjatrader and the stop loss order was executed. With his computer turned off, Ninja was not around to cancel the profit order on the exchange book.

So looking at their position. Long order stopped out so they are flat with a short order sitting on the exchange books. That short order does not have a stop loss or profit target. Just a short order sitting there.

So one of three things can happen

  1. The market does not rally, And at the end of the day, the order cancels with out being executed
  2. The market goes up and hits his stop and then plummets , making him boatloads of money
  3. The market goes up, hits his stop and keeps going up and blows a lot of cash before the end of day or end of margin ( whichever comes first )

The third scenario is why you really should know where your orders live. If you want the safety of being able to turn off your computer and walk away in the middle of a trade, use a broker that keeps your OCO order on their server or host Ninjatrader somewhere.

SO WHAT ELSE COULD GO WRONG ?

Let’s see. Besides walking away from your computer.. Floods, power outages, locusts, system lockups and your two year old turning off your power-strip because it had a pretty light. Anything that can go wrong , will.

So when you lose connectivity or you computer catches fire or whatever. You can always call your your broker and ask him to take your account flat.

You do have to think about these things especially if you are auto trading. One of my clients asked me to write code so when his laptop battery was low on power, close all of his trades. He normally trades with the power attached to his laptop, but just in case he stepped out after entering a trade, his laptop would continue to move his stops.

SO WHERE IS MY ORDER ?

Here is a list of brokers/technologies and where the OCO orders are handled. Basically, TD Ameritrade & IB support it, for everyone else, the orders live on your computer.

Zen-Fire OCO Handled by your PC
Vision Financial Markets OCO Handled by your PC
Interactive Brokers OCO Handled by the broker
Patsystems OCO Handled by your PC
PFGBEST.com OCO Handled by your PC
Trading Technologies OCO Handled by your PC
MB Trading OCO Handled by your PC
GAIN Capital/Forex.com OCO Handled by your PC
TD Ameritrade OCO Handled by the broker
FuturesBetting OCO Handled by your PC

Photo curtesy of dave_7

Trade ZenFire From Your iPhone

Posted by TraderWerks | Indicators | Tuesday 9 February 2010 2:29 am

beat-zenfire

MOBILE IS EVERYWHERE

Now, I don’t Trade on the iPhone. I think the term ‘fat finger error’ would take on a whole new meaning if I traded from an iPhone.

There a few programs for trading on the iPhone. iSwim from thinkOrSwim, E*Trade Mobile Pro and of course the Interactive Brokers app.

Having access to my trading platform on something I can carry with me is great. For me, there is some comfort in being able to check my position when I am done trading for the to make sure I am flat. Or if there is a problem with my internet connection, I can still flatten all my positions.

ZENFIRE ON THE IPHONE

ZenFire has a Webtrader in beta, which is expected RSN ( Real Soon Now ). I have no idea when, so don’t quote me on it.

You can try it at beta.zen-fire.com You can select an iPhone interface or the iPhone interface upon login.

They changed to a new darker look, which I do not care for that mch. I much prefer the old color scheme shown here.

TRADERWERKS ON THE IPHONE
This site runs on both the iPhone/iPod Touch and Google’s Android. Just point your browser to http://blog.traderwerks.com just like your normal web browser would and the magic happens auto-magically.

Next Page »