NexusFi: Find Your Edge


Home Menu

 





Help with adding new code to existing oscillator indicator script


Discussion in NinjaTrader

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




 
Search this Thread

Help with adding new code to existing oscillator indicator script

  #1 (permalink)
kendallw4
Raleigh, USA
 
Posts: 3 since May 2011
Thanks Given: 0
Thanks Received: 1

I’m new to Ninjatrader and have really struggled with coding thus far but trying to learn it. I want to write code into the attached Ninjascript that will signal a BUY arrow on the oscillator when the following conditions occur:

REI line below -40 for 6 or fewer consecutive bars AND
Close[1] < Close[2] AND
Open [0] <= High[1] and High[2] AND
(High[0] > High[1]) OR (High[0] > High[2]) AND High[0]>Open[0]


I also want it to cancel the above BUY condition signal if the following occurs:

REI line below -40 for 7 or more consecutive bars


Can someone help me with this?


///<summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///</summary>
protectedoverridevoid Initialize()
{
Add(
new Line(Color.Blue, -45, "Lower"));
Add(
new Line(Color.Blue, 45, "Upper"));


Add(
new Plot(Color.LimeGreen, "DeMarkREI_Plot_Up"));
Add(
new Plot(Color.Red, "DeMarkREI_Plot_Down"));

rei =
new DataSeries(this);
}
///<summary>
/// Calculates the indicator value(s) at the current index.
///</summary>
protectedoverridevoid OnBarUpdate()
{
if (CurrentBar>period)
{
double SUM=0;
double SUMABS=0;
double DeMarkREI=0;
double TDREI=0;

for(int x=0; x<period; x++)
{
SUM += ((High[x]-High[x+
2])+(Low[x]-Low[x+2]));
SUMABS += (Math.Abs(High[x]-High[x+
2])+Math.Abs(Low[x]-Low[x+2]));
}

if (SUMABS>0) DeMarkREI=SUM/SUMABS;
TDREI=
100*DeMarkREI;
rei.Set(TDREI);


if (Rising(rei))
{
if (!wasRising) DeMarkREI_Plot_Rising.Set(1,rei[1]);
DeMarkREI_Plot_Rising.Set(TDREI);
wasRising=
true;
}
else
{
if (wasRising) DeMarkREI_Plot_Falling.Set(1,rei[1]);
DeMarkREI_Plot_Falling.Set(TDREI);
wasRising=
false;
}
}
}
#region Properties

///<summary>
///</summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries DeMarkREI_Plot_Rising
{
get { return Values[0]; }
}
///<summary>
///</summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries DeMarkREI_Plot_Falling
{
get { return Values[1]; }
}
///<summary>
///</summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries DeMarkREI_Values
{
get { return rei; }
}
[Description(
"Number of bars to calculate")]
[Category(
"Parameters")]
publicint Period
{
get { return period; }
set { period = Math.Max(1, value); }
}

#endregion

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Deepmoney LLM
Elite Quantitative GenAI/LLM
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
  #3 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,615 since Aug 2010
Thanks Given: 1,071
Thanks Received: 5,988


kendallw4,

It is easier to get help here if you attach the zip file of the NT code so that it can be modified.

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
kendallw4
Raleigh, USA
 
Posts: 3 since May 2011
Thanks Given: 0
Thanks Received: 1

zip file of base indicator attached

Attached Files
Elite Membership required to download: demarkrei.zip
Reply With Quote
Thanked by:




Last Updated on June 9, 2011


© 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