Download Forexecutor
Powerful FX Softwarebr.

Call us now...

Skype Meâ„¢! @ tradingintl

Inteliscript Examples

   Related Information

   o 14 Day 4xCharts Trial
   o More Info / Purchase

Keep in mind these are for informational purposes only. Having listed the following here, we are not endorsing the performance or accuracy of any of them, but rather offering this as an extension of our customer service.

  1. How can I program a "trailing" stop?


  2. How do I program WMA period of 5 to cross up on the WMA period of 20 when the currency is 20 pips or greater above the WMA 20? How can I program the reverse for a short order WMA 5 cross down WMA 20?


  3. Would I create a custom indicator that takes a EMA(10) of DPO(20)?


  4. Am using a 1 hr 20 day chart. How can I retrieve last weeks high?


  5. How can I set up a sell alert for RSI crossing above 70 pips and XXX cross above 25 and a buy alert for RSI cross below 30 and XXX cross above 25? How can I also include a trailing stop of say 20 pips?

  6. How can I create an alert that will let me know if a candle changes by 10 or more pips?


  7. How can I create an alert when Schaff Trend Cycle is greater than 80 or greater than 20?

  8. I have created a custom Indicator which is attached to a 15-min 10-day GBP/USD chart to read a bar from 1-hr 30-day data series. However, the getValue returns closing price from the 15-min chart instead of one hour chart! Why is this happening?

  9. How do I add a filter of 10 pips. So I only get an alert when and if the price breaks above the chaos oscillator and then keeps moving by 10 pips?

  10. Would it be possible to add the Aroon horn to your list of indicators?

  11. How can I set up my charts so that every time the DPO (16) crosses above or below the 000.00 line giving me an alert?

  12. What commands can I use to express the last trade was a short exit? What command can I use to express the last trade was a loss?

  13. Is there a command I can use that will allow me to get the day of the week of a particular bar?

  14. I have this syntax for two time frames starting at the 4 hr then looking at the 1 hour, how can I modify this to be able to go down one more step to the 15 minute. The 1 hour looks at the "hourposition" which refers up to the 4 hour, but if I want the 15 minute to look up to the 1 hour I can't use the same "hourposition" description. Anyway of doing this?

  15. Here is a script that doesn’t appear to work, any ideas?

  16. I would like to run a backtest of a formula that references 2 different time scales using the Advanced Custom backtest feature. How can I do this?

  17. How can I apply a buy signal when the RSI set at 9 dips below 25 and take profit of 15 pips later? How can I apply a sell signal when the RSI set at 9 goes above 75 and take profit 15 pips later?

  18. Can I use line numbers if I want to use a 'goto' statement?

  19. I have drafted a script which gives fantastic back testing results, however in real time it does not give the same results. Why is that?

  20. My alert generates historical data which is then used to make decisions in realtime. Is there a way to know when you are in live mode?

  21. How can I get 3 different alerts, each one attached to a different chart, to give me a single buy or sell signal? (If all 3 alerts, from 3 different charts, are buys then I want to generate a single buy signal and if all 3 alerts, from 3 different charts, are sells then I want to generate a single sell signal.)

  22. How can I generate a sound alert if the MACD Histogram crosses up or down the zero line?

  23. How can I create an indicator to plot the highest high for the last 20 periods, as well as the lowest low over the last twenty periods?

  24. I would like to create an alert when WMA 34 and WMA 100 comes within 6 pips of each other.

  25. How can I create an alert for the Heikin Ashi to alert me when the bar changes color?

  26. I would like to write my own pivot point calculation. Is this possible to do in the IntelliScript?

  27. My alert system uses confirmations on 3 different timeframes. Is the tick by tick backtesting software capable of testing for these conditions?

  28. Tell me the last two trades entry and exit levels. I have a script that I want to know if the last trade made a profit.

  29. Tell me the last two trades entry and exit levels. I have a script that I want to know if the last trade made a profit.

  30. When I draw support and resistance lines using the "add line" tool, is there any way these lines can be recognized using the IntelliScript code?

  31. It there a code that can find the absolute highs and lows over a certain period or given a candles date stamp, can I enter it in and have the system use the slope?

 Q1: How can I program a "trailing" stop?

A1: Using a trailing stop allows you to let profits run while cutting losses at the same time. Below is an example of a 50 pip trailing stop:

IF isBuyPosition() THEN
IF AdjustedLoss () > Point(50) THEN
AddBuyExit AT AdjustedPrice() - Point(50)
ENDIF
ENDIF
IF isSellPosition() THEN
IF AdjustedLoss() > Point(50) THEN
AddSellExit AT AdjustedPrice() + Point(50)
ENDIF
ENDIF

Q2: How do I program WMA period of 5 to cross up on the WMA period of 20 when the currency is 20 pips or greater above the WMA 20? How can I program the reverse for a short order WMA 5 cross down WMA 20?

A2: Example:

IF CrossUP(WMA(close, 5), WMA(Close, 20)) and Close > WMA(Close, 20) + Point(20) THEN
AddBuyentry
Endif
/*Close < WMA(Close, 20) - Point(20) or Close < WMA(Close, 5) - Point(20)*/
IF CrossDOWN(WMA(close, 5), WMA(Close, 20)) and Close < WMA(Close, 20) - Point(20) THEN
AddBuyentry
Endif

Q3: How would I create a custom indicator that takes a EMA(10) of DPO(20)?

A3: Custom indicators are created by specifying the Indicator name, the channel you wish it to reside, the color you wish to represent the indicator on your chart of choice and the value the indicator will use.

Below is an example of a custom indicator using EMA(10) of the Detrend Price Oscillator:

//Indicator EMADPO
Indicator EMADPO
EMADPO.Channel=1
EMADPO.Color="Black"
EMADPO.Value=EMA[0](Detrend_Price_Oscillator[0](Close, 20), 10)
EMADPO.Draw

Q4: I am using a 1 hr 20 day chart. How can I retrieve last weeks high?

A4: Retrieving this data requires using the “local” and “getvalue” IntelliScript commands.

The “Local” command allows you to declare a local variable in the chart. These variables reamain accessible only within the particular script in which it is included.

The “getValue” command returns the value of the expression set forth in the script. This function enables you to retrieve the value from a different data series than the one to which the script is attached.

The script for retrieving last weeks high, using a 1hr 20 day chart would be written as follows:

local wkhigh
wkhigh=getValue("eur/usd ,1 wk. 10 yr.", high[1])
HLine myhigh=wkhigh

Q5: How can I set up a sell alert for RSI crossing above 70 pips and XXX cross above 25 and a buy alert for RSI cross below 30 and XXX cross above 25? How can I also include a trailing stop of say 20 pips?

A5: To create this script a trailing stop is drafted first. Using a trailing stop allows you to let profits run while cutting losses at the same time. Below is an example of a 20 pip trailing stop:

IF isBuyPosition() THEN
IF AdjustedLoss () > Point(20) THEN
AddBuyExit AT AdjustedPrice() - Point(20)
ENDIF
ENDIF
IF isSellPosition() THEN
IF AdjustedLoss() > Point(20) THEN
AddSellExit AT AdjustedPrice() + Point(20)
ENDIF
ENDIF

To complete the script, add the following for the RSI cross alerts for a sell alert and a buy alert:

IF CrossUP(RSI[0](close, 14), 70)) and XXX[0](Close, 14, 14) > 25 THEN
AddSellentry
Endif
IF CrossDOWN(RSI[0](close, 14),30)) and XXX[0](Close, 14, 14) > 25 THEN
AddBuyentry
Endif

Q6: How can I create an alert that will let me know if a candle changes by 10 or more pips?

A6: In the FX market, currencies are always priced in pairs. The quoted price is the level where we, acting as the market maker, are willing to buy/sell the currency pair. In the wholesale market, currencies are quoted out to four decimal places, with the last placeholder called a point or a pip. A pip in most currencies is one /10,000th of an exchange rate (in USD/JPY, it is one /100th)

Syntax:

Point({floatValueExpression})

Parameter:

floatValueExpression
Float expression.

Action:

Evaluates to the appropriate decimal numbers based on the currency. The parameter floatValueExpression can be an integer or a float number.

Example:

Point(4)
/* For EUR/USD this expression returns 0.0004; for EUR/JPY this expression returns 0.04 */
IF High[0] - Low[0] > Point(10) THEN
AlertOnly "Change Over 10 Points"
ENDIF

 

Q7: How can I create an alert when Schaff Trend Cycle is greater than 80 or greater than 20?

A7:

IF Schaff_Treand_Cycle[0](Close, 10, 23, 50) > 80 THEN
AlertOnly "STC > 80"
ENDIF
IF Schaff_Trend_Cycle[0](Close, 10, 23, 50) < 20 THEN
AlertOnly "STC < 20"
ENDIF

Q8: I have created a custom Indicator which is attached to a 15-min 10-day GBP/USD chart to read a bar from 1-hr 30-day data series. The syntax I have used is as follows:

tp=GetTimePoint(0)
Midnight1=GetHour(tp) + 1
Midnight0=24+midnight1
C=getValue("GBP/USD, 1hr. 30 day", Close[Midnight1])
O=getValue("GBP/USD, 1hr. 30 day)", Close[Midnight0])

However, the getValue returns closing price from the 15-min chart instead of one hour chart! Why is this happening?

A8: In many cases it is very important to pay particular attention the syntax that needs to be used for each command option available in the IntelliScript. The above command uses the correct commands, however the use of parenthesis or commands are incorrectly used. When the syntax is properly configured is will compile correctly and yield the desired results. For the this request, the here is the proper syntax to use:

local tp=GetTimePoint(0)
local Midnight1=GetHour(tp) + 1
local Midnight0=24+midnight1
Local C=getValue("GBP/USD, 1 hr. 30 day", Close[Midnight1])
Local O=getValue("GBP/USD, 1 hr. 30 day", Close[Midnight0])

Q9: How do I add a filter of 10 pips. So I only get an alert when and if the price breaks above the chaos oscillator and then keeps moving by 10 pips?

A9: Example:

IF crossup(close[1], Chaos_Fractal_UP[1](Close) + Point(10)) THEN
AddBuyEntry
ENDIF
IF crossdown(close[1], Chaos_Fractal_DOWN[1](Close) - Point(10)) THEN
AddSellEntry
ENDIF

Q10: Would it be possible to add the Aroon horn to your list of indicators?

A10: FXtrek makes every attempt to accommodate our clients including adding indicators that our clients find useful. Our indicator development process starts with a user's request. We then research for any information on this indicator for documentation and formulas. If it is a standard indicator meaning it is non-proprietary, we then can try to add it, depending on available time and resources.

In some cases where we are not able to program an indicator within the IntelliChart, we do offer our clients the capability to use these indicators by creating them through the IntelliScript. The Aroon Indicator is a good example, here is the syntax

Local iPeriod = 10
//Indicator AroonDown
Indicator AroonDown
AroonDown.Channel=1
AroonDown.Color="Red"
AroonDown.Value= (iPeriod - LLVIndex(Low, iPeriod)) / iPeriod * 100 AroonDown.Draw
//Indicator AroonUP
Indicator AroonUP
AroonUP.Channel=1
AroonUP.Color="Blue"
AroonUP.Value= (iPeriod - HHVIndex(High, iPeriod)) / iPeriod * 100 AroonUP.Draw

Q11: How can I set up my charts so that every time the DPO (16) crosses above or below the 000.00 line giving me an alert?

A11: Syntax Example:

IF CrossUP(Detrend_Price_Oscillator[0](Close, 16), 0) THEN
AlertOnly "DPO UP"
ENDIF
IF CrossDOWN(Detrend_Price_Oscillator[0](Close, 16), 0) THEN
AlertOnly "DPO DOWN"
ENDIF

Q12: What commands can I use to express the last trade was a short exit? What command can I use to express the last trade was a loss?

A12: I don’t understand this clearly. Does Loss(1)>0 mean you would write getTradePrice(1) > 0? Or do you use the Loss(1)>0 as a command?

1. last trade was a short exit: getTradePrice(0) = 0 and getTradePrice(1) < 0

2. last trade is loss: Loss(1) > 0

The getTradePrice command will return the price of the nth position on the chart, counted from the right to the left. To reference the current price use getTradePrice(0). To reference the last price before the new bar being drawn, use getTradePrice(1)

Syntax:

GetTradePrice({0 | 1 | 2 | 3 | ...})

Parameter:

{ 0 | 1 | 2 | 3 | ...}
Required. This is the index of the bar to the left of the current bar.

Action:

Returns the price of the nth position on the chart, counted from the right to the left.

Example:

GetTradePrice(0)

/* If the last position to the left of the current bar is a buy entry position occurring at the 10th bar to the left of the current bar and if this position's entry price is 1.1612, GetTradePrice(0) = 1.1612 */

/* If the 4th last position to the left of the current bar is a sell entry position occurring at the 10th bar to the left of the current bar and if this position's entry price is 113.16, GetTradePrice(4) = -113.16 */

Q13: Is there a command I can use that will allow me to get the day of the week of a particular bar?

A13: This was never added to the syntax list

The command to use for creating the script is getDayofWeek(0). The syntax for this command can be found in the Syntax Reference tab of the IntelliScript.

Q14: I have this syntax for two time frames starting at the 4 hr then looking at the 1 hour, how can I modify this to be able to go down one more step to the 15 minute. The 1 hour looks at the "hourposition" which refers up to the 4 hour, but if I want the 15 minute to look up to the 1 hour I can't use the same "hourposition" description.

Anyway of doing this??

Local HourPosition
HourPosition = getValue( EUR/USD, 4 Hr. 40 day , getTradePrice(0))
....

A14: Write this code in 15 minutes chart.

Local onehourPos = getValue("EUR/USD,1 hr. 20 day", getTradePrice(0))

 

Q15: Here is a script that doesn’t appear to work, any ideas?

Local OneHourEURTradePos
Local 5MinEURTradePos
OneHourEURTradePos = getValue("EUR/USD,1 Hour", getTradePrice(0))
5MinEURTradePos = getValue("EUR/USD,5 min. 2 day", getTradePrice(0))
IF (OneHourEURTradePos > 0) and
(5MinEURTradePos > 0) THEN
AddBuyEntry "BUY"
IF (OneHourEURTradePos < 0) and
(5MinEURTradePos < 0) THEN
AddSellEntry "SELL”
ENDIF

A15: ***15: The script was never corrected. Just gave advise

1. Use Contract to prevent position control.

2. don't define variable starting from digits.

Q16: I would like to run a backtest of a formula that references 2 different time scales using the Advanced Custom backtest feature. How can I do this?

Is it possible to run a backtest of a formula that references 2 different time scales using the Advanced Custom backtest featue. For example, can you backtest a formula on the 1-hour chart that references data on the 4 hour chart to validate the signal on the 1-hour chart? Please advise.

A16: It is possible to backtest syntax that references two different time scales. For example, you can draft syntax attaching it to a 1 hour chart that references let us say a 4 hour chart to validate the signal on the 1 hour chart.

In order to do this, your syntax requires adding the “Hist” command and specifying the data series name you wish to reference.

For the example above, the following string needs to be included in the script:

"HIST_USD/CHF_1 Hour". //HIST_ + data series name.

** It is not clear on which chart this string should be attached to.

Q17: How can I apply a buy signal when the RSI set at 9 dips below 25 and take profit of 15 pips later? How can I apply a sell signal when the RSI set at 9 goes above 75 and take profit 15 pips later?

A17: The IntelliScript does feature specific commands for taking profit for both the buy and sell. These are “BuyTakeProfit” and “SellTakeProfit”. To set these to take the profit at 15 pips, the Point command is used.

Example:

BuyTakeProfit Point(15)
SellTakeProfit Point(15)
IF CrossDOWN(RSI(Close, 9), 25) THEN
AddBuyEntry
ENDIF
IF CrossUP(RSI(Close, 9), 75) THEN
AddSellEntry
ENDIF

 

Q18: Can I use line numbers if I want to use a 'goto' statement?

A18: Although the IntelliScript is a programming feature that allows users to create their own customized alerts and indicators, it does not use many of the programming commands to that will allow referencing lines in the script itself. The commands that have been created for the IntelliScript are mostly for referencing the charts.

Q19: I have drafted a script which gives fantastic back testing results, however in real time it does not give the same results. Why is that?

A19: In some cases syntax drafted for back testing cannot be used for real time because of the candles that are being referenced in the script.

For example, let us take a look at the following script:

IF CrossUP(XXX[-2](Close, 5) , XXX[0](Close, 10) , IF CrossUP(XXX[-2](Close, 10) , XXX[2](Close, 13, 26, 9)) THEN
AddBuyEntry
ENDIF
IF CrossDOWN(XXX[-2](Close, 5) , XXX[0](Close, 10) IF CrossDOWN(XXX[-2](Close, 10) , XXX[2](Close, 13, 26, 9)) THEN
AddSellEntry
ENDIF

XXX can represent any available indicator. The value in the brackets represents the bar that is being referenced or the displacement of the indicator. Zero displacement represents the current bar being drawn. Using a positive number references that number bar to the left of the current bar. For example using (5) references the 5 th bar from the current bar being drawn. Using a negative number, for example (-2) would represent the 2 nd bar to the right of the current bar being drawn. Since this bar has not been drawn yet it would be considered forecasting into the future.

Unfortunately the IntelliScript does not support forecasting when using indicators.

However when backtesting, bars exist both to the left and right of the bar being referenced.

2. Don't use two crossUP/CrossDOWN at one condition. It is difficult for two cross over happen at the same time. ** is this only difficult for real time testing and not backtesting and why?

 

Q20: My alert generates historical data which is then used to make decisions in realtime. Is there a way to know when you are in live mode?

A20: You can use the RealTime() command to set an alert to let you know when you are in real time mode. The syntax for the RealTime command is as follows:

** this is not in the Syntax Reference . Not sure how it should be used and what are the parameters.

IF isRealTime() THEN
...
ENDIF
IF !isRealTime() THEN
...
ENDIF

Q21: How can I get 3 different alerts, each one attached to a different chart, to give me a single buy or sell signal?

If all 3 alerts, from 3 different charts, are buys then I want to generate a single buy signal and if all 3 alerts, from 3 different charts, are sells then I want to generate a single sell signal.

Use GetValue to reference three data series.

A21: The IntelliScript does allow you to create script setting 3 different conditions that need to happen at once before setting and alert. You can string these conditions by using the AND command in between each one.

An example would be as follows:

IF (GetValue("xxxxx", isBuyPosition()) and GetValue("xxxxx", isBuyPosition()) and GetValue("xxxxx", isBuyPosition()))
AddBuyEntry Contract="ALL"
ENDIF
IF (GetValue("xxxxx", isSellPosition()) and GetValue("xxxxx", isSellPosition()) and GetValue("xxxxx", isSellPosition()))
AddSellEntry Contract="ALL"
ENDIF

 

Q22: How can I generate a sound alert if the MACD Histogram crosses up or down the zero line.

A22: The following example will generate a sound alert using the MACD Histogram.

IF CrossUP(MACD_Hist.[0](Close, 12, 26, 9), 0) THEN
AddBuyEntry
ENDIF
IF CrossDOWN(MACD_Hist.[0](Close, 12, 26, 9), 0) THEN
AddSellEntry
ENDIF

 

Q23: How can I create an indicator to plot the highest high for the last 20 periods, as well as the lowest low over the last twenty periods?

A23: The IntelliScript features a user friendly method when creating your own indicators making it hasle free.

Simply launch the IntelliScript Organizer and select the tab labeled Indicator. In the area labeled "Create Customized Indicator", you may assign a Name, select the channel to place your indicator, the color you would like it to appear in, as well as what this indicator will do in the Value box. Once you have entered your changes, the script will be shown in the window under “Expression”

Here is an example of a script referencing high and low for the request above:

//Indicator Ind1
Indicator Ind1
Ind1.Channel=0
Ind1.Color="Yellow"
Ind1.Value= HHV(High, 20)
Ind1.Draw
//Indicator Ind2
Indicator Ind2
Ind2.Channel=0
Ind2.Color="Green"
Ind2.Value=LLV(Low, 20)
Ind2.Draw

 

Q24: I would like to create an alert when WMA 34 and WMA 100 comes within 6 pips of each other.

A24: Example:

IF ABS(WMA(Close, 34) - WMA(Close, 100)) <= Point(6) THEN
AlertOnly "WMA in Range"
ENDIF

Q25: How can I create an alert for the Heikin Ashi to alert me when the bar changes color?

A25:

IF HA_Close[0](Close) > HA_Open[0](Close) THEN
AlertOnly "Turn Blue"
ELSE
AlertOnly "Turn Red"
ENDIF

Q26: I would like to write my own pivot point calculation. Is this possible to do in the IntelliScript?

A26: Example script for the Pivot Point Calucator:

Local dayC = getValue("1 day 6 mo.", Close[1])
Local dayH = getValue("1 day 6 mo.", High[1])
Local dayL = getValue("1 day 6 mo.", Low[1])
Local MyPivot, H1, H2, H3, H4, L1, L2, L3, L4
MyPivot = (dayH + dayL + dayC) / 3
L2 = 2 * MyPivot - dayH
H2 = 2 * MyPivot - dayL
H4 = MyPivot - L2 + H2
L4 = MyPivot - H2 + L2
H3 = (H2 + H4) / 2
L3 = (L2 + L4) / 2
H1 = (MyPivot + H2) / 2
L1 = (MyPivot + L2) / 2
HLine Pivot1 = MyPivot
Pivot1.Color = "Yellow"
HLine MyM3 = H1
MyM3.Color = "Black"
HLine MyR1 = H2
MyR1.Color = "Red"
HLine MyM4 = H3
MyM4.Color = "Black"
HLine MyR2 = H4
MyR2.Color = "Red"
HLine MyM2 = L1
MyM2.Color = "Black"
HLine MyS1 = L2
MyS1.Color = "Blue"
HLine MyM1 = L3
MyM1.Color = "Black"
HLine MyS2 = L4
MyS2.Color = "Blue"

Q27: My alert system uses confirmations on 3 different timeframes.

Is the tick by tick backtesting software capable of testing for these conditions?

A27: Yes the Tick Backtesting Lab does offer this capability. To do so, add the confirmations to the three time frames in the Tick Lab adding syntax to reference each other such as:

“EUR/USD, 1M”.

The available intervals are as follows:

"1M","3M", "5M","10M","15M","30M","45M"
,"1H","2H","3H","4H","6H"
,"8H","1D","1W","1M"

  

Q28: tell me the last two trades entry and exit levels. I have a script that I want to know if the last trade made a profit.

A28: Profit(0) is the current open position, Profit(1) is the last trade profit/loss.

Q29: I want to place an arrow or winding on the chart without pacing a buy or sell signal.

I tried h_lines but they did not work well. Text, different colored arrows, smiley faces, anything.

A29: We don't have that yet.

Unfortunately, at this time the IntelliChart does not support the capability to add arrows on the charts from the “Drawing” menu or from the IntelliScript.

Q30: When I draw support and resistance lines using the "add line" tool, is there any way these lines can be recognized using the IntelliScript code?

A30: The you may reference lines on the chart within code using the IntelliScript. To do so, right mouse click on the line of your choice and assign a label. You may then use the line label preceded by an underscore within your code to reference this specific line. For example, if a trend line has been labeled ABC, to refer to this line in your code use this syntax: _ABC

 

Q31: It there a code that can find the absolute highs and lows over a certain period or given a candles date stamp, can I enter it in and have the system use the slope?

A31: function HHV/LLV. *** I think this was covered earlier in #23