Wizard Example2

ICE Data Services -


Example #2: Alerts on MACD Crosses


In this example formula, we want to be notified when the MACD signal line crosses the MACD oscillator line. Notification will take the form of a post to the Alert List, and a sound played from a .wav file. We will not be displaying the MACD, but instead display up and down arrows directly on the price chart where the signal crosses above and below the oscillator.

Formula Configuration

Select price study, and click OK. Since we are not plotting the MACD itself, we do not need to return any lines in the Data Plots Table.


Click on Add Study and add a MACDStudy with the desired parameters:

Expression Sets

We will have two expression sets, one to handle the cross up case, and the other to handle the cross down case. Add a condition line to the first expression set:

On the left side, click on Edit, and select our previously added study variable name: vMACD12_26:


Under the dataSeriesID parameter, be sure to select MACDStudy.SIGNAL. This will return the value of the MACD's signal line to the left side of our condition line.

Click on OK, then click on the right Edit button. Select our study variable name again vMACD12_26:


This time, keep the default dataSeriesID as MACDStudy.MACD. You should now have a condition line that looks like this:


This sets up our first case, where the signal has crossed under the MACD oscillator. The first thing we would like to at this point is to add a popup alert to the Alert List. Click on the Add Line next to the actions that execute only the first time, and select the addToList function:


For our description, type in  MACD Signal Cross Down , and select an appropriate color to use to represent this event. The action line should now look like this:


Next, we want to play a sound file to provide an audio alert. Click on Add Line again, and select playSound. We can use the default sound file that is already filled in. The action lines should now look like this:


The final action will be to draw a down arrow on the bar where the crossover occurs. Click on Add Line again, but this time select the drawShapeRelative function:


Select high() as the yValue (the price value on the y-axis where the shape will be drawn), Shape.DOWNARROW as the shape to draw, an appropriate color, and Shape.BOTTOM as the alignment flag, so that our arrow points in the correct location.

Expression Set #1 should now look like the following:



To complete Expression Set #2, click on Set 2 and follow the same steps, this time taking care to reverse the sign from <to >, and selecting the appropriate description and colors to signal a cross in the opposite direction.

Expression Set #2 should look similar to this:



Returned Data Points

No data points are returned in this study, as we are not plotting the MACD directly.





The green arrows mark the locations where the MACD signal has crossed above the MACD oscillator. The red arrows mark the locations where the signal has moved below the oscillator.

In addition, when this is run in real-time (or in Replay Mode), alerts are generated and posted to the Alert List:

Return to Formula Wizard Guide