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
Noob Questions
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Noob Questions
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.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)?
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.
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: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?
Code: Select all
protected override void CalcBar()
{
if (Bars.LastBarOnChart)
{
// Only executes on the last bar
}
}
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.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
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.
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.)4. Can i round off any prive value to the nearest tick value (i.e. s&p emini price as in increments of .25)?
-
- Posts: 2
- Joined: 01 Nov 2016
Re: Noob Questions
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
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
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Noob Questions
I don't know of another way to do this besides using code.I can do this the hard way by using alot of code but i was wondering if there is an easy solution