Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Constant line(MIN(BB bandwidth, period))
Collapse
X
-
Constant line(MIN(BB bandwidth, period))
With my limited programming skills I'm trying to plot the minimum value of an indicator looking back n periods. I would like that value as a constant line. Any ideas? Tried to modify the constant line indicator without any success. Shouldn't be too difficult, or?Tags: None
-
Oh, I get a lot of errors I'm afraid... I think the core issue though is what you suggest; to index the MIN method. But how do i do that? Using the private double method, or? I'd really appreciate if you could give me an example then I can fiddle with it a bit more.
Comment
-
Thank you both for your replies. I'm almost there now, but it doesn't exactly do what I want. Here is the code:
#region Variables
privateint minperiod = 100;
#endregion
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
protectedoverridevoid OnBarUpdate()
{
double minimum = MIN(Bollingerbandwidth(2,14), minperiod)[0];
Plot0.Set(minimum);
Please take a look at this picture I uploaded: http://www.pixbox.se/pic_show_id29954163.html If you look at the 2nd last panel you'll see the "constant" minimum value plotted. You see that there is a drop in the last values. Why is that? It is set on exclude weekends and calculate on bar close: false.
Comment
-
Well, it appears it doesn't really do what I want it to do (se the simple code below).
I would like it to take the minimum value of Bollingerband n days back (including checking the latest close) and plot that value as a constant line (for all days), like a support line.
protectedoverridevoid OnBarUpdate()
{
double minimum = MIN(Bollingerbandwidth(2,18), minperiod)[0];
Plot0.Set(minimum);
}
Possible?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jonker, 04-27-2024, 01:19 PM
|
3 responses
22 views
0 likes
|
Last Post Today, 05:45 PM | ||
Started by businessman1929, 04-29-2024, 01:28 PM
|
2 responses
21 views
0 likes
|
Last Post Today, 05:38 PM | ||
Started by bltdavid, 03-27-2023, 05:32 AM
|
18 responses
347 views
0 likes
|
Last Post
by ETFVoyageur
Today, 05:28 PM
|
||
Started by NM_eFe, Today, 05:15 PM
|
0 responses
5 views
0 likes
|
Last Post
by NM_eFe
Today, 05:15 PM
|
||
Started by vitaly_p, Today, 05:09 PM
|
0 responses
4 views
0 likes
|
Last Post
by vitaly_p
Today, 05:09 PM
|
Comment