Position closed alert not working  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 33 times

Position closed alert not working

Postby darob » 27 Oct 2018

Hi, I've been trying to get an alert to fire when an autotraded position is closed but I'm having no luck. Below are two efforts. Can anyone offer suggestions? Many thanks.

Code: Select all

using System;

namespace PowerLanguage.Strategy {

[IOGMode(IOGMode.Enabled)]
public class Position_Closed_Alert : SignalObject {
public Position_Closed_Alert(object _ctx):base(_ctx){}

private VariableObject<Double> m_position;

protected override void Create() {
m_position = new VariableObject<Double>(this);
}
protected override void CalcBar(){
if (StrategyInfo.MarketPositionAtBroker == 0){
m_position.Value = 0;
}
if (StrategyInfo.MarketPositionAtBroker != 0){
m_position.Value = 1;
}
if (m_position[0] != 1
&& m_position[1] != 0){
Alerts.Alert("Postion closed | Check autotrade status");
}
}
}
}

Code: Select all

using System;

namespace PowerLanguage.Strategy {

[IOGMode(IOGMode.Enabled)]
public class PositionClosed_Alert : SignalObject {

private int alertTrig;

public PositionClosed_Alert(object _ctx):base(_ctx){}

protected override void StartCalc(){
alertTrig = 0;
}
protected override void CalcBar(){
if(StrategyInfo.MarketPositionAtBroker != 0){
alertTrig = 1;
}
if(StrategyInfo.MarketPositionAtBroker == 0
&& alertTrig != 0){
Alerts.Alert("Pos'n Closed | Check AT");
alertTrig = 0;
}
}
}
}

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

Re: Position closed alert not working  [SOLVED]

Postby Henry MultiСharts » 29 Oct 2018

Hello darob,

Make sure to enable the alerts for the signals in Format->Strategy Properties->Alerts tab:
http://www.multicharts.com/trading-soft ... egy_Alerts


Return to “MultiCharts .NET”