Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
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)
Little coding help needed
Updated April 10, 2014
Top Posters
looks_one
Abde
with 5 posts (2 thanks)
looks_two
Tasker_182
with 2 posts (4 thanks)
looks_3
Silvester17
with 1 posts (5 thanks)
looks_4
Fat Tails
with 1 posts (4 thanks)
Best Posters
looks_one
Silvester17
with 5 thanks per post
looks_two
Fat Tails
with 4 thanks per post
looks_3
Tasker_182
with 2 thanks per post
looks_4
Abde
with 0.4 thanks per post
trending_up
1,665 views
thumb_up
15 thanks given
group
4 followers
forum
8 posts
attach_file
1 attachments
Little coding help needed
April 10th, 2014, 08:02 AM
Stuttgart / Germany
Experience: Intermediate
Platform: FlatTrader
Broker: GFT and Interactive Brokers
Trading: ES, DAX
Frequency: Every few days
Duration: Days
Posts: 533 since Aug 2010
Thanks Given: 2,141
Thanks Received: 729
Iīm trying to define the bar open and close as precondition in an code snippet.
If the bar open and close is located in the upper/lower third of the bar range , than do something.
if(Open[0] && Close[0] >= (High[0] + Low[0])/1.5 && (VOL ()[0]>VOL()[1]))
The "if(Open[0] && Close[0]" is the part that didnīt work. Iīve searched the NT help guide and www, but couldnīt find anything helpful.
Has anyone an idea how I can set the open and close as a precondition?
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
April 10th, 2014, 08:14 AM
Berlin, Europe
Market Wizard
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102
Abde
Iīm trying to define the bar open and close as precondition in an code snippet.
If the bar open and close is located in the upper/lower third of the bar
range , than do something.
if(Open[0] && Close[0] >= (High[0] + Low[0])/1.5 && (
VOL ()[0]>VOL()[1]))
The "if(Open[0] && Close[0]" is the part that didnīt work. Iīve searched the NT help guide and www, but couldnīt find anything helpful.
Has anyone an idea how I can set the open and close as a precondition?
- open and close located in the upper third
- meaning: reversal bar up with a lower shadow that exceeds 2/3 of the bar range
Code
if( Math.Min (Open[0], Close[0]) > (2*High[0] + Low[0])/3.0)
- open and close located in the lower third
- meaning: reversal bar down with an upper shadow that exceeds 2/3 of the bar range
Code
if( Math.Max (Open[0], Close[0]) < (High[0] + 2*Low[0])/3.0)
April 10th, 2014, 08:21 AM
Cedar Rapids, iowa
Legendary Market Wizard
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401
Abde
Iīm trying to define the bar open and close as precondition in an code snippet.
If the bar open and close is located in the upper/lower third of the bar
range , than do something.
if(Open[0] && Close[0] >= (High[0] + Low[0])/1.5 && (
VOL ()[0]>VOL()[1]))
The "if(Open[0] && Close[0]" is the part that didnīt work. Iīve searched the NT help guide and www, but couldnīt find anything helpful.
Has anyone an idea how I can set the open and close as a precondition?
Hi Adbe,
Just for clarity, the if statement is looking for a logical true/false in which to move. Each side of && has to resolve to True or false To work. The statement part Open[0] doesn't have any T/F evaluation as written. , here is what it would need to look like:
if((Open[0] >= (High[0] + Low[0])/1.5 && (VOL()[0]>VOL()[1]))) && (Close[0] >= (High[0] + Low[0])/1.5 && (VOL()[0]>VOL()[1])))
@FatTails of course offers a superior method.
Be yourself; everyone else is already taken. Oscar Wilde
April 10th, 2014, 08:44 AM
Columbus, OH
Market Wizard
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527
Abde
Iīm trying to define the bar open and close as precondition in an code snippet.
If the bar open and close is located in the upper/lower third of the bar
range , than do something.
if(Open[0] && Close[0] >= (High[0] + Low[0])/1.5 && (
VOL ()[0]>VOL()[1]))
The "if(Open[0] && Close[0]" is the part that didnīt work. Iīve searched the NT help guide and www, but couldnīt find anything helpful.
Has anyone an idea how I can set the open and close as a precondition?
@Abde ,
here's an indicator that does something similar
edit: this is an old indicator I found here. don't know who made it. but I definitely would use @Fat Tails logic
Attached Files
Elite Membership required to download: ReversalBars.cs
April 10th, 2014, 09:20 AM
Stuttgart / Germany
Experience: Intermediate
Platform: FlatTrader
Broker: GFT and Interactive Brokers
Trading: ES, DAX
Frequency: Every few days
Duration: Days
Posts: 533 since Aug 2010
Thanks Given: 2,141
Thanks Received: 729
Fat Tails
- open and close located in the upper third
- meaning: reversal bar up with a lower shadow that exceeds 2/3 of the bar
range
Code
if( Math.Min (Open[0], Close[0]) > (2*High[0] + Low[0])/3.0)
- open and close located in the lower third
- meaning: reversal bar down with an upper shadow that exceeds 2/3 of the bar range
Code
if( Math.Max (Open[0], Close[0]) < (High[0] + 2*Low[0])/3.0)
A big thank you @Fat Tails for the kind help!
It works perfect and is by the way, a very elegant solution.
April 10th, 2014, 09:57 AM
Stuttgart / Germany
Experience: Intermediate
Platform: FlatTrader
Broker: GFT and Interactive Brokers
Trading: ES, DAX
Frequency: Every few days
Duration: Days
Posts: 533 since Aug 2010
Thanks Given: 2,141
Thanks Received: 729
Tasker_182
Hi Adbe,
Just for clarity, the if statement is looking for a logical true/false in which to move. Each side of && has to resolve to True or false To work. The statement part Open[0] doesn't have any T/F evaluation as written. , here is what it would need to look like:
if((Open[0] >= (High[0] + Low[0])/1.5 && (
VOL ()[0]>VOL()[1]))) && (Close[0] >= (High[0] + Low[0])/1.5 && (VOL()[0]>VOL()[1])))
@FatTails of course offers a superior method.
Hi @Tasker_182 ,
Thanks for tying to help. Have tested your provided code, but unfortunately it didnīt work (Compile).
Maybe I did something wrong, here is the code how I used it:
Code
if(( Open [ 0 ] >= ( High [ 0 ] + Low [ 0 ])/ 1.5 && ( VOL ()[ 0 ]< VOL ()[ 1 ]))) && ( Close [ 0 ] >= ( High [ 0 ] + Low [ 0 ])/ 1.5 && ( VOL ()[ 0 ]< VOL ()[ 1 ])));
April 10th, 2014, 10:01 AM
Cedar Rapids, iowa
Legendary Market Wizard
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401
Abde
Hi @
Tasker_182 ,
Thanks for tying to help. Have tested your provided code, but unfortunately it didnīt work (Compile).
Maybe I did something wrong, here is the code how I used it:
Code
if(( Open [ 0 ] >= ( High [ 0 ] + Low [ 0 ])/ 1.5 && ( VOL ()[ 0 ]< VOL ()[ 1 ]))) && ( Close [ 0 ] >= ( High [ 0 ] + Low [ 0 ])/ 1.5 && ( VOL ()[ 0 ]< VOL ()[ 1 ])));
Hi Abde,
I wasn't trying to write your correct code, i was trying to help you understand that having Open[0] by itself was not a condition of true of false and that the correct way to write the condition based on your code was what i was showing. Sorry I should have been more clear.
Be yourself; everyone else is already taken. Oscar Wilde
April 10th, 2014, 11:36 AM
Stuttgart / Germany
Experience: Intermediate
Platform: FlatTrader
Broker: GFT and Interactive Brokers
Trading: ES, DAX
Frequency: Every few days
Duration: Days
Posts: 533 since Aug 2010
Thanks Given: 2,141
Thanks Received: 729
Silvester17
@
Abde ,
here's an indicator that does something similar
edit: this is an old indicator I found here. don't know who made it. but I definitely would use @Fat Tails logic
Thanks @Silvester17 for posting the ReversalBars, which I didnīt had before.
Itīs a interesting one because of the selectable wick percent feature. But of course, I will use Fat Tails code for my purpose.
April 10th, 2014, 11:45 AM
Stuttgart / Germany
Experience: Intermediate
Platform: FlatTrader
Broker: GFT and Interactive Brokers
Trading: ES, DAX
Frequency: Every few days
Duration: Days
Posts: 533 since Aug 2010
Thanks Given: 2,141
Thanks Received: 729
Tasker_182
Hi Abde,
I wasn't trying to write your correct code, i was trying to help you understand that having Open[0] by itself was not a condition of true of false and that the correct way to write the condition based on your code was what i was showing. Sorry I should have been more clear.
@Tasker_182 ,
Ok have understood. Will have a closer look to study it and try to make it work for learning purposes.
Last Updated on April 10, 2014