Indicator does not generate alert when price crosses VPOC

Questions about MultiCharts .NET and user contributed studies.
Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Indicator does not generate alert when price crosses VPOC

Postby Abhi » 13 Mar 2019

Hi, I am using the below code, the indicator generate should generate alert when the close of the bar crosses below or above the volume profile.

For some reason, alert is never generated, what am I doing wrong here.



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

namespace PowerLanguage.Indicator{
[SameAsSymbol(true)]
[UpdateOnEveryTick(true)]
[SkipIdenticalTicks(false)]
public class AG_Test : IndicatorObject
{
public AG_Test(object _ctx):base(_ctx)
{
}
private IPlotObjectStr Vol_POC_VA;
private VariableSeries<Double> VPOCDoubleSeries;

protected override void Create()
{
Vol_POC_VA = AddPlot(new StringPlotAttributes());
VPOCDoubleSeries = new VariableSeries<Double>(this);
}
protected override void StartCalc()
{
//subscribing for profile changes
VolumeProfile.EChanged += VolumeProfileOnEChanged;
}
protected override void CalcBar()
{
// indicator logic
int bn = Bars.FullSymbolData.Current-1;
var vp = VolumeProfile.ItemForBar(bn);
if (vp != null)
{
double VolValue = (double)vp.POC.TotalValue;
VPOCDoubleSeries.Value = VolValue ;
double PriceValue = (double)vp.POCForBar(bn).Dbl;
if ( VolValue > 49999)
{
Vol_POC_VA.Set(string.Format("P={0:n2},V={1:n0}", PriceValue ,VolValue), Color.Yellow);

if ( this.CrossesOver(VPOCDoubleSeries,Bars.Close) || this.CrossesUnder(VPOCDoubleSeries,Bars.Close))
{
Alerts.Alert("Test");
}

}else

{
Vol_POC_VA.Set(string.Format("P={0:n2},V={1:n0}", PriceValue ,VolValue), Color.White);

}

}
}
private void VolumeProfileOnEChanged(bool full)
{
//Recalculate if the profile has been completely changed.
if (full)
this.ExecControl.Recalculate();
}

}
}

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 15 Mar 2019

if ( this.CrossesOver(VPOCDoubleSeries,Bars.Close) || this.CrossesUnder(VPOCDoubleSeries,Bars.Close))
{

Hi, I may be all wet, but is Bars.Close just the last traded price when UpdateEveryTick is set to true, and therefore never crossed?

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 15 Mar 2019

darob wrote:if ( this.CrossesOver(VPOCDoubleSeries,Bars.Close) || this.CrossesUnder(VPOCDoubleSeries,Bars.Close))
{

Hi, I may be all wet, but is Bars.Close just the last traded price when UpdateEveryTick is set to true, and therefore never crossed?



Thanks Darob for the suggesstion, I ticked off that option, didn't work.

Henry, Svetlana anyone with any suggestions. please could you help.

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 15 Mar 2019

The other thing I'm wondering is if Bars.Close should be first in the expression ie this.CrossesOver(Bars.Close, VPOCDoubleSeries).

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 15 Mar 2019

tried that also, didn't work.

User avatar
Henry MultiСharts
Posts: 9047
Joined: 25 Aug 2011
Has thanked: 1250 times
Been thanked: 2905 times

Re: Indicator does not generate alert when price crosses VPOC

Postby Henry MultiСharts » 15 Mar 2019

Hello Abhi,

You need to make sure the alerts for the indicator are enabled in the settings:
Indicator: http://www.multicharts.com/trading-soft ... ing_Alerts
If an alert was not generated, then the condition for generating it has not been met.
You will need to add output logic to debug it.

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 20 Mar 2019

Henry MultiСharts wrote:Hello Abhi,

You need to make sure the alerts for the indicator are enabled in the settings:
Indicator: http://www.multicharts.com/trading-soft ... ing_Alerts
If an alert was not generated, then the condition for generating it has not been met.
You will need to add output logic to debug it.


I can assure you Henry that the alert has been setup correctly and the VPOC values are generated correctly as I display them on the status line. every time the close crosses the VPOC value, it never generates an alert. please can you help when you get a chance! not asking you to help immediately. I know you guys are busy.

The latest code


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

namespace PowerLanguage.Indicator{
[SameAsSymbol(true)]
[UpdateOnEveryTick(true)]
[SkipIdenticalTicks(false)]
public class AG_Test : IndicatorObject
{
public AG_Test(object _ctx):base(_ctx)
{
}
private IPlotObjectStr Vol_POC_VA;
private VariableSeries<Double> VPOCDoubleSeries;

protected override void Create()
{
Vol_POC_VA = AddPlot(new StringPlotAttributes());
VPOCDoubleSeries = new VariableSeries<Double>(this);
}
protected override void StartCalc()
{
//subscribing for profile changes
VolumeProfile.EChanged += VolumeProfileOnEChanged;
}
protected override void CalcBar()
{
// indicator logic
int bn = Bars.FullSymbolData.Current-1;
var vp = VolumeProfile.ItemForBar(bn);
if (vp != null)
{
double VolValue = (double)vp.POC.TotalValue;
double PriceValue = (double)vp.POCForBar(bn).Dbl;
VPOCDoubleSeries.Value = PriceValue ;
if ( VolValue > 49999)
{
Vol_POC_VA.Set(string.Format("P={0:n2},V={1:n0}", PriceValue ,VolValue), Color.Yellow);

if ( this.CrossesOver(Bars.Close, VPOCDoubleSeries) || this.CrossesUnder(Bars.Close, VPOCDoubleSeries))
{
Alerts.Alert("Test");
}

}else

{
Vol_POC_VA.Set(string.Format("P={0:n2},V={1:n0}", PriceValue ,VolValue), Color.White);

}

}
}
private void VolumeProfileOnEChanged(bool full)
{
//Recalculate if the profile has been completely changed.
if (full)
this.ExecControl.Recalculate();
}

}
}
Attachments
Tradestation.wsp
(171.69 KiB) Downloaded 44 times

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 22 Mar 2019

Hi Abhi, I've got one more suggestion (and that's it, promise :wink: ) The indicator recalculates after a profile change, but maybe this isn't frequent enough to fire the alert. You could try adding a time-based recalculation in CalcBar():
Screen Shot 2019-03-22 at 10.29.24 AM.png
Screen Shot 2019-03-22 at 10.29.24 AM.png (11.04 KiB) Viewed 504 times

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 25 Mar 2019

Hi Darob, I am open to all suggestions, you can give as many as you want, I will be very glad to try out. I tried the above option of recalculating after both 1 and 10 seconds, didn't work.

Just thinking out loud - the crossover and crossunder interfaces take two double series as parameters and compares and when the price crosses above or under should generate an alert. There is no time factor in it.

That's what it does in the moving average indicator, where it takes moving average values for each bar and the close values of each bar as parameters and generates alert when the condition is met.

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 25 Mar 2019

Hi Abhi,

I thought I’d suggest it because as a novice and for the practice I built the VA_Min_Max indicator that Multicharts has provided and found it works when first applied to a chart, but when I change instruments on the chart it doesn’t reload unless the status button in the format indicators dialogue is toggled. I found adding the time based recalculation makes it work as I think it’s supposed to.

I’m not sure what the implications are for your purposes when the MC example apparently isn’t working correctly either.

I should probably let the experts take it from here. Thanks for the feedback.

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 26 Mar 2019

Hi Darob, I was not giving a feedback I was just telling my opinion :) I am no better than you in Multicharts c# coding. I have done easy language coding and c# in ICMarkets but Multicharts .NET has a steep learning curve.

As you said, let's wait for the expert to comment. Like I said earlier, if you have any more suggestions happy to try out.

User avatar
Henry MultiСharts
Posts: 9047
Joined: 25 Aug 2011
Has thanked: 1250 times
Been thanked: 2905 times

Re: Indicator does not generate alert when price crosses VPOC

Postby Henry MultiСharts » 17 Apr 2019

Abhi wrote:
Henry MultiСharts wrote:I can assure you Henry that the alert has been setup correctly and the VPOC values are generated correctly as I display them on the status line. every time the close crosses the VPOC value, it never generates an alert. please can you help when you get a chance! not asking you to help immediately. I know you guys are busy.
Abhi, are you able to get the alerts generated for the prebuilt indicators, for example, playback a chart with the ADX indicator applied and alerts enabled in the settings?
What if you add traces to your own code next to the alert generation logic, is the trace added to the output when the alert is supposed to be generated?

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 29 Apr 2019

Hi Abhi and Henry. Was this ever solved? When volume profile is enabled I’ve found that alerts involving vp levels don’t always fire when set to bar close, but when set to once per bar they do. Is this by design? (I’m referring only to setups that are valid at bar close.)

User avatar
Henry MultiСharts
Posts: 9047
Joined: 25 Aug 2011
Has thanked: 1250 times
Been thanked: 2905 times

Re: Indicator does not generate alert when price crosses VPOC

Postby Henry MultiСharts » 15 May 2019

darob wrote:Hi Abhi and Henry. Was this ever solved? When volume profile is enabled I’ve found that alerts involving vp levels don’t always fire when set to bar close, but when set to once per bar they do. Is this by design? (I’m referring only to setups that are valid at bar close.)
Hello darob,

The alert condition needs to be fulfilled on the calculation performed on the bar close for the alert to be triggered.
If that is the case, but the alert is not triggered, please send us the code and the workspace for replicating this behavior on our end.
Detailed instructions/screenshots/video demonstrating the issue will be helpful as well.

darob
Posts: 174
Joined: 20 Nov 2014
Has thanked: 46 times
Been thanked: 23 times

Re: Indicator does not generate alert when price crosses VPOC

Postby darob » 15 May 2019

Hi Henry, I've sent you the code etc. I've also managed to get this to work for my purposes by offsetting the calculation 1 bar so that when the once per bar alert fires I in fact have the close I'm waiting for. Obviously it would be good to understand why this is necessary.

Thanks

User avatar
Henry MultiСharts
Posts: 9047
Joined: 25 Aug 2011
Has thanked: 1250 times
Been thanked: 2905 times

Re: Indicator does not generate alert when price crosses VPOC

Postby Henry MultiСharts » 17 May 2019

darob,

We were unable to replicate this behavior on our end using the provided data.
If you want to continue the analysis - I would recommend adding Bars.Status value output next to the alert command in your code.
If output shows EBarState.Close, but the alert is not triggered, this is something to look into.
These users thanked the author Henry MultiСharts for the post:
darob

Abhi
Posts: 26
Joined: 28 Nov 2015
Has thanked: 5 times
Been thanked: 1 time

Re: Indicator does not generate alert when price crosses VPOC

Postby Abhi » 21 Jun 2019

darob wrote:Hi Abhi and Henry. Was this ever solved? When volume profile is enabled I’ve found that alerts involving vp levels don’t always fire when set to bar close, but when set to once per bar they do. Is this by design? (I’m referring only to setups that are valid at bar close.)



Many apologies Darob, completely forgotten to reply. Never worked for me. But I am not looking at the these kind of alerts anymore so I didn't pursue any further.


Return to “MultiCharts .NET”