Alerts when stops are triggered


Thanks very much for helping me with all my previous queries. It helped me make good progress.

Now I am setting up email alerts and its working well using the code below

AlertIF( Buy, “EMAIL”, "MACDCrossOver : Buy : "+ BuyPrice, 1 );
AlertIF( Sell, “EMAIL”, “MACDCrossOver : Sell :”+ SellPrice, 2 );
AlertIF( Short, “EMAIL”, “MACDCrossOver : Short :”+ ShortPrice, 3 );
AlertIF( Cover, “EMAIL”, “MACDCrossOver : Cover :” + CoverPrice, 4 );

Also I have stoploss defined like this
ApplyStop( stopTypeNBar, stopModeBars, nbar );

How can I be alerted when a stoploss gets triggered? I understand applystop() does NOT return any values. If it had I could have used that in the trade signals.

If it already exists, a reference to the link will help.

Look for Equity function in amibrokers help.

You would need to add Equity(1) to your formula. it would evaluate stops and write them to sell/cover arrays, see

From then on the rest is easy:

Hi for a strategy with scaling in/out, Equity(1) doesn't work as it affects the backtest results. How should we set up alerts in this case?


Equity(1); // to populate stops in Sell array

AlertIf(Buy,"EMAIL","Buy half position in "+Name(),type=1);
AlertIf(Sell==1,"EMAIL","Sell all of "+Name(),type=2);
AlertIf(Sell==2,"EMAIL","Stopped out due to max loss. Sell all of "+Name(),type=2);
AlertIf(Sell==5,"EMAIL","Stopped out due to max bars. Sell all of "+Name(),type=2);`