NexusFi: Find Your Edge


Home Menu

 





Basic Indicator Issues


Discussion in NinjaTrader

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




 
Search this Thread

Basic Indicator Issues

  #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?
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
44 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (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


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,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,608


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 Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on February 19, 2015


© 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