NexusFi: Find Your Edge


Home Menu

 





Comparing a bar with your body size?


Discussion in NinjaTrader

Updated
    1. trending_up 1,550 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 eryo 
Babia, Spain
 
Experience: Intermediate
Platform: ninja trader
Broker: zen fire
Trading: gold
Posts: 48 since Apr 2010
Thanks Given: 22
Thanks Received: 8

Hi. I have no knowledge of programming.
I want to know the size of the body of a bar and get it with this code:

Value.Set(Math.Abs(Open[0]-Close[0]));

Now I want that if the size of the body of the bar is greater than 10 bar draw yellow.
NinjaTrader forum have given me this code

if (Value[0] > 10)
BarColor = Color.Yellow;

But does nothing.
Can anyone tell me the correct way to write the code?
Thank you.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
Iran and Israel Stand Down: What $9M in Peace Contracts …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Since I gather you want to test if body is greater than eg. 10 ticks you need to multiply the values of your Value by TickSize:

 
Code
Value.Set(Math.Abs(Open[0]-Close[0])*TickSize);
Also if you have no programming experience always use {} after if, eg.:
 
Code
if (Value[0] > 10)
{
    BarColor = Color.Yellow;
}
This will help you avoid unintentional errors;


Reply With Quote
Thanked by:




Last Updated on February 18, 2016


© 2026 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 - Downloads - Top
no new posts