Noob Questions

Questions about MultiCharts .NET and user contributed studies.
MontyDamji
Posts: 2
Joined: 01 Nov 2016

Noob Questions

Postby MontyDamji » 01 Nov 2016

Hi

I am new to multicharts.net coding however i have written several EA's and indicators on MT so i am familiar with coding

I have a few questions and hope someone can guide help me understand these concepts:

1. I noticed that CalcBar method is called on every new bar, can i set some parameters to make CalcBar be called on every price movement (tick)?

2. When i load my signal on a chart and query for the current open price, the calc bar method reads all the historical bars on the chart untill it gets to the current bar. I dont want that instead i wast just the current price. Can this be done?

3. I have manually placed trend lines on a chart and have my signal fetch all the trend lines and i can access their properties. I would like to do the same with horizontal lines, is this possible? I do not want to use horizontal trend lines instead i would like to use horizontal lines

4. Can i round off any prive value to the nearest tick value (i.e. s&p emini price as in increments of .25)?

Thanks for the help folks

Monty

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

Re: Noob Questions

Postby JoshM » 02 Nov 2016

1. I noticed that CalcBar method is called on every new bar, can i set some parameters to make CalcBar be called on every price movement (tick)?
For indicators there's an option called 'Update on Every Tick' in the indicator's setting screen that makes the `CalcBar()` method update with every price tick or once per bar, depending on whether this option is enabled or disabled.

There's also a class attribute (`UpdateOnEveryTick`), that configures the same but then programmatically. For more on both approaches, see updating an indicator on every tick.

For signals, the script calculates once per bar, when the bar closes, if the intra-bar order generation option is turned off. When we turn that option on, then `CalcBar()` processes every price update of that bar. For more on that option and how to set it, see intra-bar order generation.
2. When i load my signal on a chart and query for the current open price, the calc bar method reads all the historical bars on the chart untill it gets to the current bar. I dont want that instead i wast just the current price. Can this be done?
You can use the `Bars.LastBarOnChart`property to check whether the script currently calculates on the current bar (that is, the last bar of the data series) or not. For instance:

Code: Select all

protected override void CalcBar()
{
if (Bars.LastBarOnChart)
{
// Only executes on the last bar
}
}
Note that the `CalcBar()` method will be executed for each and every bar of the data series. So while we can use `Bars.LastBarOnChart` to prevent code from executing unless the bar is the last bar of the series, it's not possible to prevent the `CalcBar()` method from entering/executing at all. That's just how MultiCharts .NET works.
3. I have manually placed trend lines on a chart and have my signal fetch all the trend lines and i can access their properties. I would like to do the same with horizontal lines, is this possible? I do not want to use horizontal trend lines instead i would like to use horizontal lines
That's not possible, unfortunately. Of the MultiCharts .NET standard drawings, we can only make trend lines, arrows, and text boxes programmatically, but not horizontal lines.

You can, of course, use a regular trend line and plot this line so that it becomes a horizontal trend line. An example of that is here: plotting horizontal trend lines.
4. Can i round off any prive value to the nearest tick value (i.e. s&p emini price as in increments of .25)?
This sounds like you may have a wrong setting in the QuoteManager, since S&P E-mini prices should normally already plot in 0.25 increments on the chart. You might want to check the 'Price Scale' option in the QuoteManager for those symbols. See setting properties in the QuoteManager for how to configure that. (On that page, the 'Price Scale' option is discussed near the end of the page, in the table.)

MontyDamji
Posts: 2
Joined: 01 Nov 2016

Re: Noob Questions

Postby MontyDamji » 02 Nov 2016

Hi Josh

Thanks for the very detailed response. Very helpfull.

On the last point where i am trying to round off a price value to the closest tick, the reason behind is that i am writing a signal where i will use trendlines to define targets where i would be moving my stop loss to. Now more often than not, i wont have my trendline on the exact tick value hence i would like to round off to the nearest tick value where i can place my stop loss.

I can do this the hard way by using alot of code but i was wondering if there is an easy solution

Thanks

Monty

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

Re: Noob Questions

Postby JoshM » 04 Nov 2016

I can do this the hard way by using alot of code but i was wondering if there is an easy solution
I don't know of another way to do this besides using code.


Return to “MultiCharts .NET”