FREE TOOLS
Currency Quotes
Clocks (Large)
Links & Offers
Expert Articles

EXPERT ARTICLES

<< Back to Category
IntelliScript: Simple Crossover Alerts

In recent weeks, the use of the term death-cross or terminal-cross has been pushed around with regard to the Dow Jones Industrial Average (listed as US30 under the CFD's chart options). This simple cross refers specifically to the cross down of the 50 SMA (simple moving average) over the 200 SMA.

Enlarge Chart

Figure 1. US30 Terminal Cross.

Figure 1 shows the terminal cross that happened on 08/23/2011. This type of crossover has several benefits:

The crossover also has drawbacks:

However from a programming standpoint, the simple crossover requires a good deal of planning and thought. The following is a basic script that alerts the user to the crossover with the appropriate Buy/Sell signal at the crossover.

IF CrossUP(SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addBuyEntry
endif

IF CrossDown(SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addSellEntry
endif

Though this script is effective at identifying the crossover, it is good for little else. For instance, if you hadn't selected the "Calculate on Close Only" option in Set Alert Properties, the user could possibly be alerted several times of the impending cross. Until the candle is closed, price action may alternately create SMA's that are crossed and uncrossed. To remedy this simply check the "Calculate on Close Only" option box in the Alert window of the Intelliscript organizer, or use the following script.

IF barClosed() and CrossUP(SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addBuyEntry
endif

IF barClosed() and CrossDown( SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addSellEntry
endifbarClosed()

This however, may still not provide the execution needed. If you use crossovers to trade your live account with Auto-Trade, you will need to exit the previous position first. This can be handled with the following script.

if barClosed() and isSellposition and CrossUP(SMA[0](Close, 5), SMA[0](Close, 15)) then
     addSellExit
endif

if barClosed() and isBuyposition and CrossDOWN(SMA[0](Close, 5), SMA[0](Close, 15)) then
     addBuyExit
endif

if barClosed() and CrossUP(SMA[0](Close, 5), SMA[0](Close, 15)) then
     addBuyEntry
endif

if barClosed() and CrossDown(SMA[0](Close, 5), SMA[0](Close, 15)) then
     addSellEntry
endif

This script first Checks the appropriate conditions as well as whether or not there is a signal. Keep in mind that Intelliscript run in a script fashion from top to bottom without skipping lines of code. Users must put the code in the order it needs to executed in.

For a little more advanced script, you may want to reference a longer term chart to see if price is overbought or oversold. This can be accomplished using the getValue reference and RSI(14).

IF barClosed() and getValue("EUR/USD,4 hr. 40 day", RSI[0](Close, 14)) < 50
  and CrossUP(SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addBuyEntry
endif

IF barClosed() and getValue("EUR/USD,4 hr. 40 day", RSI[0](Close, 14)) > 50
  and CrossDown(SMA[0](Close, 50), SMA[0](Close, 200)) THEN
     addSellEntry
endif

These may not be the prettiest Intelliscripts or the most condensed code, however, they are simple, easy for users to understand and perform the functions properly. Please remember that these scripts are for Intelliscript demonstration purposes only. You should test your own scripts and strategies before trading live.