User login

  

Basic Concepts

There are a few available scripts for C# and VB:

  • Indicator
  • Trading System
  • Macros
  • NinjaScript Indicators (you need to refer to the NinjaTrader's documentation to learn about this type of script)

In your scripts you are able to use most of the system, platform and language-specific functions from ptl, mql2, mql4, el.

For fast viewing of function's (constant's, variables's) description  use Dictionary or Intellisence.

Once you create a script,  by the  default, project template provides a skeleton by  listing the essential functions.

As rule C# and VB scripts include next regions:

  • Libraries declaration
  • Initialization region
  • Entry points
  • Input parameters

Libraries declaration

This region include standard template Libraries.

For indicators and strategies you need to declare PTLRuntime.NETScript to use  platform and language-specific functions. 

Initialization region

Initial region include module's properties and protection information:

  • Author -developer's name
  • Comments - this is a  visual name of your script
  • Company - developer's company
  • Copyrights - developer's (C) copyright
  • Date Of Creation - module's date of creation
  • Version - module's version
  • Project Name - module's version

Entry points

The function OnQuote is the main entry point to the Indicator and Trading System script. The OnQuote() method is called each time a new quote is received.
You must override Entry methods in your strategy or indicator with the following syntax: 


//  C#
public override void OnQuote()

{
//  -- Enter your code here --  
}


//  VB
Overrides Sub OnQuote()

'  -- Enter your code here -- 
End Sub

Only one entry function is required for the Indicator and Trading System to operate.

Trading Systems and Indicators also have some other entry points:

  • public override void Init()
  • public override void Complete()
  • public override void NextBar() - only for Indicators
  • public override void OnNewLevel2Quote()

The function Init() is a call in auto mode, when module starts, and the function Complete() is a call in auto mode when module finishes. The NextBar() function is called each time a new bar from is received (depends on Chart period).  

The function OnQuote() is called every time a new quote is received. So if you need to run some code before the main sequence (OnQuote), then put this code into the Init() function, and if you need some code to run after the module sequence, then put this code into the Complete() function.

The function OnQuote() is the main function in the Strategy and Indicator, and is therefore called every time new quotes are received. The OnNewLevel2Quote()  is called very time new Level 2 quote is received.

Note: When Chart period value set as tick, there are no difference between NextBar() and OnQuote() function

 In your Trading Systems and Indicators you may specify additional functions, methods, classes, input parameters, etc.

Input Parameters

You may specify input parameters for your indicator using InputParameter function. Skeleton of the project doesn't include this function.
Use InputParameter if you need to change some values after compilation of the module.

For example, to create Input Parameter with the name Param1, default value 5 and order number 0 you need to type after Indicator Line Set and before OnQuote function:

    [InputParameter("Parameter description", 0)]
     public int Param1 = 5;

To create Input Parameter with the limited list of values:

  [InputParameter("Description of parameter", 1, new object[] {
            "value1 description", value1,

            "value2 description", value2,
            "valu3 description", value3,
            "value4 description",value4}

Note! whole list of avalable parameters you may view in ProTrader using Intellisance.

12345

Comments