Modify charpoint of manual trendline  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
pdemontferrier
Posts: 22
Joined: 22 Jun 2017
Has thanked: 9 times
Been thanked: 2 times

Modify charpoint of manual trendline

Postby pdemontferrier » 26 Mar 2019

Hello every one.

I draw manually trends on a window. But often flat trends are difficult to make really flat.
This is why I'm looking for a code that will correct the price value of the end charpoint of the trend line.
I'm struggling on the final part, if someone could help me to fix this it will be very helpful for me.
Thank you in advance for you collaboration.

Code: Select all

protected override void CalcBar()
{

if (Bars.LastBarOnChart && CHRONO_START == 0 )
{
CHRONO_START++;

foreach (ITrendLineObject MVT in DrwTrendLine.GetTrendLineObjects(EDrawingSource.Manual))
{
//Set MVT values
MVT_TIME_BEG = MVT.Begin.Time.AddMinutes(-Bars.Info.Resolution.Size);
MVT_TIME_END = MVT.End.Time;
MVT_PRICE_BEG = MVT.Begin.Price;
MVT_PRICE_END = MVT.End.Price;
MVT_AMP = Math.Abs(MVT.End.Price - MVT.Begin.Price);

if ( MVT_AMP < 5 )
{
MVT.End.Price = MVT.Begin.Price; // *********this part doesn't work*********

}
}
}
}

pdemontferrier
Posts: 22
Joined: 22 Jun 2017
Has thanked: 9 times
Been thanked: 2 times

Re: Modify charpoint of manual trendline  [SOLVED]

Postby pdemontferrier » 29 Mar 2019

Hi every one,

Thank to Josh and it's very helpful website I found the solution :

Code: Select all


if ( (MVT.End.Price - MVT.Begin.Price) < 5 && (MVT.End.Price - MVT.Begin.Price) != 0)
{
MVT.End = new ChartPoint (MVT.End.Time,MVT.Begin.Price);
}
Find here under the link to Josh website : Tradingcode.net

Regards


Return to “MultiCharts .NET”