NexusFi: Find Your Edge


Home Menu

 





Comparing a bar with your body size?


Discussion in NinjaTrader

Updated
    1. trending_up 1,601 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?
Datafeed for Atas
Platforms and Indicators
Daytrading to swingtrading
Traders Hideout
No book, only a stair: journaling fills where price move …
Cryptocurrency
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
BERN ALGOS algo trading journal
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