NexusFi: Find Your Edge


Home Menu

 





Basic Indicator Issues


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Quick Summary with 1 posts (0 thanks)
    2. looks_two halliwm with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (1 thanks)
    4. looks_4 Fat Tails with 1 posts (0 thanks)
    1. trending_up 1,643 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 halliwm 
Calgary
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Piano
Posts: 2 since Mar 2013
Thanks Given: 1
Thanks Received: 0

Hi, I have been trying to create a simple indicator that takes the amount of time in a period before the latest low and a high and charts it. Basically it is ((period - bars since high/low)/period)*100. I am having trouble getting it to plot, it just shows up as flat line at 0. I also tried to print the values but I get nothing.

I've included the code below but I also have a question about DataSeries. Do I need to create a DataSeries for the indicator values to be stored in? and if not what types of indicators do you use it for? And lastly I am determining which bar out of the period contains the high or low through a for loop. Is there a better method to finding those bar index's? Cheers and thanks in advance.



// Wizard generated variables
private int numPeriod = 1; // Default setting for NumPeriod

// User defined variables (add any user defined variables below)
private double outputHigh;
private double outputLow;
private int highIndex;
private int lowIndex;
private double highest;
private double lowest;



protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "HighOutput"));
Add(new Plot(Color.FromKnownColor(KnownColor.Maroon), PlotStyle.Line, "LowOutput"));
Overlay = false;
CalculateOnBarClose = false;
}

protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.

if (CurrentBar<numPeriod)
{
return;
}

else
{
// first needs to find how many bars since high and low and store them in their respective variables.

//Could do a for loop to determine index position of high and low

//Assumes current bar has high/low
highest=CurrentDayOHL().CurrentHigh[0];
lowest=CurrentDayOHL().CurrentLow[0];

for (int i=1; i<numPeriod; i++)
{
if (Bars.GetDayBar(i).High > highest)
{
highest=Bars.GetDayBar(i).High;
highIndex=i;

}
if (Bars.GetDayBar(i).Low<lowest)
{
lowest=Bars.GetDayBar(i).Low;
lowIndex=i;
}

}

//store in respective output variables
outputHigh=((numPeriod-highIndex)/numPeriod)*100;
outputLow=((numPeriod-lowIndex)/numPeriod)*100;



//set plots
HighOutput.Set(outputHigh);
LowOutput.Set(outputLow);

}

}


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114


You would need to attach your entire indicator file. This is too difficult to read and noone can test it for bugs.

To attach files you will probably need a few more posts (I think it was 5 posts that are required).


Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557


Fat Tails View Post
To attach files you will probably need a few more posts (I think it was 5 posts that are required).

Everyone can attach files from post 1. You can't embed URL's with < 5 posts.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on February 19, 2015


© 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