Inside Bar Function

Questions about MultiCharts .NET and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Inside Bar Function

Postby turbofib » 28 Jul 2014

hi, i need to use Inside Bar function ...
i see indicator Inside_Bar but not is function

i must to create this function or is already available

Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Inside Bar Function

Postby Henry MultiСharts » 28 Jul 2014

Hello turbofib,

There is no built-in "Inside_Bar" function. That is possible to create your own function that will perform the required calculations.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Inside Bar Function

Postby turbofib » 29 Jul 2014

i create this function :

Code: Select all

namespace PowerLanguage
{
namespace Function
{
public sealed class InsideBar : FunctionSeries<System.Boolean>
{
public InsideBar(CStudyControl _master) : base(_master) { }
public InsideBar(CStudyControl _master, int _ds) : base(_master, _ds) { }

public Int32 n { get; set; }


protected override System.Boolean CalcBar()
{
if ((Bars.High[n-1]<=Bars.High[n]) && (Bars.Low[n-1]>=Bars.Low[n])) return(true);
else return(false);


}
}
}
}
when i call it from other function...i must to create

Code: Select all

private Function.InsideBar _InsideBar;

_InsideBar = new Function.InsideBar(this);
Or is there a way more simple to call the function insidebar(See Bars.Close BArs.Volume .....I do not have to instantiate an object of class)

Thanks

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Inside Bar Function

Postby JoshM » 29 Jul 2014

Or is there a way more simple to call the function insidebar(See Bars.Close BArs.Volume .....I do not have to instantiate an object of class)
You could create an extension method. See here for a MultiCharts .NET example of that.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Inside Bar Function

Postby turbofib » 29 Jul 2014

thanks but it 's too hard to do ... I'm at the beginning of c #

Is there someone who can give me a hand in creating it? thank you very much

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Inside Bar Function

Postby Henry MultiСharts » 29 Jul 2014

turbofib, you need to create an instance of the function like in your post #3.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Inside Bar Function

Postby JoshM » 02 Aug 2014

Or is there a way more simple to call the function insidebar(See Bars.Close BArs.Volume .....I do not have to instantiate an object of class)
See the example below for how to use an extension method for detecting an inside bar. This does not require instantiating an function object class, but you can just call the `Bars.InsideBar()` method.

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
public class ForumExample_InsideBar : IndicatorObject
{
public ForumExample_InsideBar(object _ctx) : base(_ctx) { }

protected override void CalcBar()
{
if (Bars.Status == EBarState.Close)
Output.WriteLine("{0} - Is this an inside bar? {1}",
Bars.Time[0].ToString("d-M-y HH:mm:ss"),
Bars.InsideBar());
}
}
}

namespace PowerLanguage
{
public static class MyExtensions
{
public static bool InsideBar(this ISeriesSymbolData bar)
{
if ((bar.High[0] <= bar.High[1]) && (bar.Low[0] >= bar.Low[1]))
return true;
return false;
}
}
}


Return to “MultiCharts .NET”