Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Mike, I'm not sure how the download section for code snippets will work since most snippets I've seen are only a portion of a working code...
My programming experience came from finding indicators built-in to NT or on the NT support forum (that I could then rename with a _v01) and then proceed to try new things that I was learning at the time. I started using the wizard several months ago and am now able to customize some of the indicators and strategies that I like to use.
I'd appreciate others sharing code snippets that you find worthwhile. I'll share a couple things I like to use here and in the following posts:
PLOTTING LINES OF VARIOUS SIZE / COLOR
This shows up with line width 1 and may be too narrow to see well plus I never understood "FromKnownColor" purpose.
or
3 lines of code required...
- okay, now I've got the line width built-in to the plot command...
For newbies the process of learning how to get things to plot are quite a challenge - i.e. the difference required when using DashStyle.Dash and PlotStyle.Line. I can't begin to calculate how many hours I spent trying to get plots to work... Plotting in Strategies is another matter...
if you look at your character map for these different fonts (Webdings, Wingdings, etc.), you'll soon see some useful graphics that will help highlight your charts. You just have to figure out what keystroke is required to give you the desired symbol.
In OnBarUpdate for a larger Wingdings "l" (small-case L) solid circle,
This allows you to use the font size from variables to make as large as you need.
Good idea zeller. Here's some code I came up with from various samples to give me some peace of mind if you were to run your strategies unattended. (in case I ever have a strategy that makes money!!!)
This is probably very simplistic and old hat for many, but hopefully it will help someone. It can be easily personalized with your own messages, input variables, etc.
You're welcome. I place it at the very top of OnBarUpdate as a standard first thing it always checks for. Also, keep in mind that it doesn't actually stop the strategy, but only prevents it from taking any more trades for that session, which is also necessary so that it doesn't interfere with backtesting.
I'm still mulling over how to provide a "store" of code snippets in a way that makes them easy to find and easy to figure out how to integrate into a custom code file... within the futures.io (formerly BMT) forum construct... (or possibly "without" - in the mathematical sense - it may be best to create a wiki type environment which can be linked to from within futures.io (formerly BMT)).
An example is the one I did on how to code sound alerts.. but that takes a lot of time and I wouldn't want to require that from all contributors... however there is no question that we need categories to organize them... "fundamentals"; "data definitions and usage"; "plotting and drawing"; "referencing objects from other code files"; "performance tips and tricks"; "order handling", etc.
Programming some code today I discovered an error that is unusual and took me a while to solve.
Very occasionally on an IB feed I noticed that my entryprice vs current price in ticks was out by 1 ie 10t profit was showing as 9t in my code but NOT all the time.
Eventually I reasoned that it's due to some internal rounding that NT does. It is most noticeable on forex futures eg 6E.
The solution seems messy but it does work
price = Close[0] or whatever you want;
Obviously for a short position you would invert the above code (entryprice - price)
NT Support recommends that any indicator that is used within a strategy NOT have any reference to CalculateOnBarClose ...
I looked at a random sample of the default indicators and they do not have COBC in their code. I tried it myself for backtesting a strategy and it does make a small difference in outputs (depending on the complexity of the indicator)