NeedForTrade Blog
NeedForTrade Studio Blog

Creating BollingerBands_LE Strategy

December 26, 2007 23:03 by support

Creating BollingerBands_LE Strategy

There is a detailed description of creation of BollingerBands_LE strategy.

At first:

  1. Use the File menu.
  2. Select New.

    image

  3. Select Strategy.

Now you can see Code Editor. It's empty.

image

Click with the right mouse button anywhere in the Code Editor window.

image

In the shortcut menu select Properties and enter strategy name in the field Analysis Technique|Name at the Properties window.

image 

Enter the name: "BollingerBands_LE". "_LE" means that this strategy produces only Long Enter orders, this is a good practice to mark strategies in such way (although it's not required). After filling name field this strategy name will appear at the end of the list of strategies in Browser. We want to write this strategy on C# so keep field Language without changes too.

image 

Click the right mouse button anywhere in the Code Editor window again. Now in the shortcut menu select Parameters. We need to enter input parameters for this strategy:

  1. BollingerPrice parameter (it will tell strategy against what price bollinger band must be calculated).
  2. TestPrice parameter (specifies prices that will be compared to bollinger band to decide whether trade order should be generated).
  3. Length parameter (specifies number of bars back used to calculate bollinger band).
  4. NumDevsDn parameter (number of deviations down - required to calculate bollinger band).

image

To add parameters click right mouse button on the Parameters box and in the shortcut menu select Add Parameter and special form will appear.

image

In this form enter Parameter name, Parameter type, Parameter default value, Parameter description and if necessary mark that parameter is Reference. Than click Save if you want to save this parameter or Discard if you don't.

Creating BollingerPrice parameter: enter Parameter name ("BollingerPrice") and select Parameter type ("DoubleSeries"), set Parameter default value ("C") and than click Save.

 image

Creating TestPrice parameter: again click right mouse button on the Parameters box and in the shortcut menu select Add Parameter. Now enter Parameter name ("TestPrice") and select Parameter type ("DoubleSeries"), set Parameter default value ("C") and click Save.

 image

Creating Length parameter: again click right mouse button on the Parameters box and in the shortcut menu select Add Parameter. Now enter Parameter name ("Length") and select Parameter type ("Integer"), set Parameter default value ("20") and click Save.

image

Creating NumDevsDn parameter: again click right mouse button on the Parameters box and in the shortcut menu select Add Parameter. Now enter Parameter name ("NumDevsDn") and select Parameter type ("Integer"), set Parameter default value ("2") and click Save.

image

So we filled Parameters box:

image

This strategy uses two functions: BollingerBandFunction and CrossesOver. So we must add them as references. To do it select Functions from Browse for list of Browser window:

image

Browser window will show all available Functions:

image 

Find BollingerBandFunction and drag it with lift mouse button and drop over References window. Proceed the same with CrossesOver function.

After that References window will show that strategy references two functions:

image 

To calculate BollingerBands_LE strategy we need to define variable LowerBand in Variable Store. It will holdseries of values that represent Bollinger Band curve. To define it go to the Variable Store window, right-click on it and select Add Variable from context menu:

image 

Variable edit window will appear:

image

Enter Variable name ("LowerBand") and Variable type ("DoubleSeries"). Click Save.

image

Now enter the code of BollingerBands_LE strategy into the Code Editor window.

image

Strategy is executed on every bar of loaded data range.

At first we are checking that we have enough data:

[code:c#]

if (Bars.Count >= Length)
{
    //we have enough data
}

[/code]

The following line calculates LowerBand by calling BollingerBandFunction:

[code:c#]

LowerBand[0] = BollingerBandFunction(BollingerPrice, Length, -NumDevsDn );

[/code]

This line defines buying condition (Buy if this is not a first bar and TestPrice crosses over LowerBand):

[code:c#]

if ( CurrentBar > 1 && CrossesOver(TestPrice, LowerBand) )

[/code]

Generating Buy order:

[code:c#]

BuyNextBarAtStop("BBandLE", LowerBand[0]);

[/code]

where "BBandLE" - order name and LowerBand[0] - stop price.

 

After all listed actions are done click right mouse button anywhere in the Code Editor window and select Build Analysis Technique. If there are no errors in the Strategy it will appear in the list of functions at Browser with the green tick. Otherwise Task List will appear. For example if you forgot semicolon it will display in Task List with indication of concrete line and file name with error.

image

When you will find the error and correct it click the right mouse button anywhere in the Code Editor window and select Build Analysis Technique again. If there are no errors in the Strategy now Task List will be empty and function name will appear in the list of Strategies at Browser with the green tick.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Creating Text Data File Format Preset

October 18, 2007 06:38 by Support

Creating Text Data File Format Preset

To open ASCII Data Import window:

  1. Make a Chart Window active or create a new one.
  2. Click the right mouse button anywhere in the chart window background and select the Symbol Properties from the context menu or double-click anywhere in the chart window background and Symbol Properties window will appear. 
  3. Click Lookup in the General tab and Symbol Lookup window will appear. 
  4. Select symbol for which you want to import data.
  5. Click Import Data button. 
  6. ASCII Data Import window will appear.

You can see ASCII Data Import window below.

image

To create new text data file format preset:

  1. Specify file to import. You can navigate through you computer folders using Up button to go one level up in the folder structure and window image . Selected file name will appear in the text box image .
  2. Contents of selected file can be previewed in the text box image
  3. Click on Add button (image ) to create a new preset. Enter new preset name in Create Preset dialog and click Create button.
  4. Set preset properties here: image . These properties are:
    • BarType - type of bars contained in file.
    • PriceMultiplier - (usually it's 1) .
    • StartingLine - first data line in file (counts from 1). In this example it's 2, because first line contains column descriptions.
    • TimeZone - specifies time zone of dates and times in file (usually it's Exchange).
    • VolumeMultiplier - (usually it's 1).
  5. Specify data fields that will describe data in file here: image . To create a new field, click on the Click to add new field field. The following menu will appear:
    image
    Select appropriate field type from this menu. To skip unused or useless data fields in file use Skipped field type.
    To delete field click Remove Field.
    For Date and Time fields try Automatic or Custom option from submenu first. If it won't work select correct date/time format from sumbenu. For detailed description of date/time format strings visit .NET Format String 102: DateTime Format String, NET Format Strings (in PDF format, Adobe Reader required) or Custom DateTime Format Strings.
  6. You can specify additional field properties by clicking on the field. Edit field's properties here: image.
  7. Preview of data, contained in selected file can be found in the list image .
  8. To import data click on Import button.

Use created preset every time you need to load data from file with the same format by selecting it from list image .

You can also perform these actions (image):

  1. Remove preset - by clicking on Remove button .
  2. Rename or copy preset - by clicking on additional actions button image .

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Importing Data From Text Files

October 18, 2007 06:34 by Support

Importing Data From Text Files

Symbol data often can be obtained in the text (ASCII) file of some format. You can use ASCII Data Import to load data stored in text files of virtually any format.

To open ASCII Data Import window:

  1. Make a Chart Window active or create a new one.
  2. Click the right mouse button anywhere in the chart window background and select the Symbol Properties from the context menu or double-click anywhere in the chart window background  and Symbol Properties window will appear. 
  3. Click Lookup in the General tab and Symbol  Lookup window will appear. 
  4. Select symbol for which you want to import data.
  5. Click Import Data button. 
  6. ASCII Data Import window will appear.

You can see ASCII Data Import window below.

image

To import data from text file you need to do the following:

  1. Specify file to import. You can navigate through you computer folders using Up button to go one level up in the folder structure and window image . Selected file name will appear in the text box image .
  2. Contents of selected file can be previewed in the text box image
  3. Select appropriate preset from the list image or create a new one. Preset describes text file format.
  4. Preview of data, contained in selected file can be found in the list image
  5. To import data click on Import button.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Creating Summation Function

October 18, 2007 03:12 by support

Creating Summation Function

There is a detailed description of creation of Summation function.

At first:

  1. Use the File menu.
  2. Select New.

    image

  3. Select Function.

Now you can see Code Editor. It's empty.

image

Click with the right mouse button anywhere in the Code Editor window.

image

In the shortcut menu select Properties and enter function name in the field Analysis Technique|Name at the Properties window.

image

Enter the name: "Summation". After filling name field this function name will appear at the end of the list of functions at Browser. Default function Type is DoubleFunction. Summation is Double function so keep this field without changes. We want to write this function on C# so keep field Language without changes too.

image

Click the right mouse button anywhere in the Code Editor window again. Now in the shortcut menu select Parameters. Enter input parameters for this Function. This Function calculates summary of Length last values, passed by Values parameter.

image

To add parameters click right mouse button on the Parameters box and in the shortcut menu select Add Parameter and special form will appear.

image

In this form enter Parameter name, Parameter type, Parameter default value, Parameter description and if necessary mark that parameter is Reference. Than click Save if you want to save this parameter or Discard if you don't.

image

For this function at first enter Parameter name ("Values") and select Parameter type ("DoubleSeries") and than click Save.

image

Than again click right mouse button on the Parameters box and in the shortcut menu select Add Parameter. Now enter Parameter name ("Length") and select Parameter type ("Integer") and click Save.

image

So we filled Parameters box:

image

For this simple function we don't need to use References and Variable Store.

Now enter the code of Summation function into the Code Editor window.

image

At first we need to define the variables and initialize them. Declare sum variable to store resulting summary and set it's default value to zero:

double sum = 0;

To calculate summary of all passed values we need to use loop.

  1. Set integer valiable i to zero: int i = 0;
  2. Set condition when to stop the loop: i < Length;
  3. Set what to do with i after each loop iteration: i++;
  4. Specify the action we need to perform in the loop (in this case we want to add i-th value to the currently counted summary): sum = sum + Value[i].

for ( int i = 0; i < Length; i++ ) sum = sum + Values[i];

Then we move to assigning calculated summary, stored in sum variable to Value variable (the actual value of the function).

Value = sum;

After all listed actions click right mouse button anywhere in the Code Editor window and select Build Analysis Technique. If there are no errors in the Function it will appear in the list of functions at Browser with the green tick. Otherwise Task List will appear. For example if you forgot semicolon it will display in Task List with indication of concrete line and file name with error.

image

When you will find the error and correct it click the right mouse button anywhere in the Code Editor window and select Build Analysis Technique again. If there are no errors in the Function now Task List will be empty and function name will appear in the list of functions at Browser with the green tick.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Importing Symbol Information from Data Provider

September 27, 2007 05:56 by Support

Importing Symbol Information from Data Provider

Prior to the first use of symbol (instrument) we need to define it. This must be done only once for each symbol. All symbols are saved in application database for later use.

For example, we want to import symbol data for IBM (International Business Machines Corporation) stock. That can be done automatically for data providers that support symbol lookup.

  • Press Import button. Import Symbol dialog will appear:

image_30

  • We want to import stock - so select Stock from Type list.
  • IBM stock is taded on NYSE Exchange - select N [NYSE] from Exchange list. 
    • Tip: To speed-up selection process you can click on Exchange List and press n key - list will be winded to a first item that starts with 'n' char.
    • Tip: Use Web Lookup, Web Symbol Guide and Supported Exchanges List links to find required instrument if you do not know it's exchange or data provider-specific symbol. (If supported by data provider).
  • Type IBM in the Symbol or Root field.
  • Press Lookup button:

image_32

  • After some time list of descovered symbols will be presented:

 image_34

  • Select IBM-N symbol from the list and press Import.
    • Tip: you can select multiple symbols at one time.
  • Imported symbols will be presented in the Symbol Lookup dialog. You will be able to use them as long as you need it without re-importing:

 image_36


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Creating Bar Chart

September 27, 2007 04:17 by Support

Creating Bar Chart

For example we will create IBM symbol bar chart with daily interval using FREE OpenTick data provider

image

  • New chart window will appear:

image 

  • Right-click on the chart window and select Symbol Properties:

image 

  • Select OpenTick Delayed data provider (or OpenTick if you have real-time account for required symbol):

image

  • If you are using OpenTick data provider for the first time Data Provider Setup dialog will appear. Please enter your OpenTick Login and Password (you can obtain them for free at www.opentick.com) in the corresponding fields and press OK:

image 

You can change data provider settings any time by selecting required data provider and pressing Setup link (on the right of Data Provider field) on Symbol Properties dialog.

  • Click on the Lookup link (on the right of the Symbol field) on the Symbol Properties dialog. Symbol Lookup dialog will appear:

image

  • We want to create bar chart for IBM (International Business Machines Corporation) stock. Prior to the first use of IBM symbol we need to define it (see Symbol Import). If it's already defined - skip this step.
  • Select IBM-N from the list on Symbol Lookup dialog and press Select:

image 

  • You will be returned to the Symbol Properties dialog:

image

  • Select Daily interval.
  • Set Last Date to some date (For example 04 Aug 2007).
  • Select Bars Back to load specified bars count back from Last Date.
  • Press OK button. Data loading process will start.
    • Tip: data loading can take some time depending on data provider and requested data range.
  • When data loading process will be completed chart data will be shown:

image


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Starting NeedForTrade Studio

September 27, 2007 04:01 by Support

Starting NeedForTrade Studio

 

For NeedForTrade Studio:

  1. Click Windows Start button.
  2. Click All Programs.
  3. Locate and click NeedForTrade Studio item.
  4. Click NeedForTrade Studio.
  5. Wait until Logon dialog will appear on the screen (it can take some time).
  6. Enter your Username and Password.
  7. Press Logon button.
  8. Wait until NeedForTrade Studio is loaded.

For NeedForTrade Studio Lite:

  1. Click Windows Start button.
  2. Click All Programs.
  3. Locate and click NeedForTrade Studio Lite item.
  4. Click NeedForTrade Studio Lite.
  5. Wait until Logon dialog will appear on the screen (it can take some time).
  6. Enter your Username and Password (you can obtain them for FREE by registering on www.NeedForTrade.com site).
  7. Press Logon button.
  8. Wait until NeedForTrade Studio Lite is loaded.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Tutorials
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed