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)
hey guys I need some help with my code. What I want to do is create a long entry when two of my systems both fire a long on the same bar. what i did is i created a boolean and put both of my strategies into one strategy called Mashall. however when i write the code, and run it.. does not work for some reason. can someone please help me decipher why this does not work.
Can you help answer these questions from other members on NexusFi?
the reason you can tell that its not working is by looking at the triangles. when the strategy is activated you never see both red and blue triangles appear on the SAME BAR.
The reason that I am not doing it that way is because i am going to have more than 2 conditions (probably around 11)
And some of the other conditions will be inverse of other conditions. For example one would say go long only on
== 20K while another would say go long on >= 30K or greater. If i would combine this, it would not work that well. So I need to learn have to do boolean in ninjatrader. But i am having a very hard time making the code work.
Hey guys just a quick question does anyone have a boolean trading system NOT INDICATOR for ninjatrader. that I can use and just put my conditions in instead of yours. your help would be appreciated
(calm down literal 'net, I know this it not optimized, just trying to show a point...)
then in your OnBarUpdate() you just stack together your predicates (true/false conditions) in easy-to-follow English
Another approach would be to track a score of a setup. So for example if you have 8 possible conditions you like to look at, and if 6 pass then you take a trade. So when each condition is valid, add +1 to your score. This is one way you can layer on more and more conditions without adding a bunch of unmanageable if/then permutations.
To me, readability is very important, because code can grow and become very complex really quickly. In my opinion OnBarUpdate() needs to be the most English-reading code you write, because these are the core rules of your strategy. The gory/technical details behind each command and condition can be defined elsewhere, but OnBarUpdate() needs to be your most coarse-grained part of your strategy/indicator to keep your sanity when modifying and maintaining your strategy.
For example, here is a strategy I've been trading live for years: my gap fading strat. This is the OnBarUpdate() method. The whole strategy is almost 700 lines long, but I can open this open and quickly refresh my memory about how it works just by looking at OnBarUpdate() even though I haven't looked at this code in a long time.