NexusFi: Find Your Edge


Home Menu

 





Little coding help needed


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Abde with 5 posts (2 thanks)
    2. looks_two Tasker_182 with 2 posts (4 thanks)
    3. looks_3 Silvester17 with 1 posts (5 thanks)
    4. looks_4 Fat Tails with 1 posts (4 thanks)
      Best Posters
    1. looks_one Silvester17 with 5 thanks per post
    2. looks_two Fat Tails with 4 thanks per post
    3. looks_3 Tasker_182 with 2 thanks per post
    4. looks_4 Abde with 0.4 thanks per post
    1. trending_up 1,664 views
    2. thumb_up 15 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread

Little coding help needed

  #1 (permalink)
 Abde 
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?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
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 View Post
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)

Reply With Quote
Thanked by:
  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
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 View Post
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
Reply With Quote
Thanked by:
  #4 (permalink)
 
Silvester17's Avatar
 Silvester17 
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 View Post
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
Reply With Quote
Thanked by:
  #5 (permalink)
 Abde 
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 View Post
- 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.

Started this thread Reply With Quote
  #6 (permalink)
 Abde 
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 View Post
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]))); 


Started this thread Reply With Quote
  #7 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
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 View Post
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
Reply With Quote
Thanked by:
  #8 (permalink)
 Abde 
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 View Post
@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.

Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 Abde 
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 View Post
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.

Started this thread Reply With Quote
Thanked by:




Last Updated on April 10, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts