NinjaScript > Editor >

Code Snippets

Print this Topic Previous pageReturn to chapter overviewNext page

Code Snippets can provide you with useful code templates to speed up your coding process.

 

tog_minusUnderstanding Code Snippet shortcuts

You can quickly add commonly used methods and code structures via

Short cut characters
Clicking on your right mouse button and selecting the menu name "Insert Code Snippet"
Pressing the F2 key on your keyboard
tog_minusHow to use Code Snippet shortcuts via the keyboard

Using the keyboard

Enter the text in the left column and press the "Tab" key within the NinjaScript Editor.

 

Current Bar Values

cb

CurrentBar

o

Open[0]

h

High[0]

l

Low[0]

v

Volume[0]

 

Previous Bar Values

c1

Close[1]

o1

Open[1]

h1

High[1]

l1

Low[1]

v1

Volume[1]

 

Arithmetic

abs

Math.Abs(value)

min

Math.Min(value1, value2)

max

Math.Max(value1, value2)

 

Control Statements

if

if (expression)

{

 

}

else

{

 

}

 
for

 

for (int index = 0; index < count; index++)

{

 

}

 
switch

 
switch (expression)

{

  case value1:

 

      break;

  case value2:

 

      break;

   default:

 

      break;

}

 

Drawing

dd

DrawArrowDown("MyArrowDown", 0, High[0], Color.Red);

du

DrawArrowUp("MyArrowUp", 0, Low[0], Color.Red);

ddi

DrawDiamond("MyDiamond", 0, High[0] + 2 * TickSize, Color.Blue);

dt

DrawDot("MyDot", High[0] + 2 * TickSize, Color.Blue);

de

DrawEllipse("MyEllipse", 10, Low[10], 0, High[0], Color.Blue);

di

DrawExtendedLine("MyExtendedLine", 10, Close[10], 0, Close[0], Color.Blue);

df

DrawFibonacciLevels("MyFibonacciLevels", 10, Close[10], 0, Close[0]);

dh

DrawHorizontalLine("MyHorizontalLine", Close[0], Color.Blue);

dl

DrawLine("MyLine", 10, Close[10], 0, Close[0], Color.Blue);

dy

DrawRay("MyRay", 10, Close[10], 0, Close[0], Color.Blue);

dr

DrawRectangle("MyRectangle", 10, Low[10], 0, High[0], Color.Blue);

ds

DrawSquare("MySquare", 0, High[0] + 2 * TickSize, Color.Blue);

dx

DrawText("MyText", "Sample text ", 0, High[0] + 2 * TickSize, Color.Blue);

dtd

DrawTriangleDown("MyTriangleDown", 0, High[0] + 2 * TickSize, Color.Red);

dtu

DrawTriangleUp("MyTriangleUp", 0, Low[0] - 2 * TickSize, Color.Blue);

dv

DrawVerticalLine("MyVerticalLine", 0, Color.Blue);

tog_minusHow to insert Code Snippets via the mouse or F2 key

Via mouse or pressing the F2 key

1. Right mouse click in the NinjaScript Editor and select the menu name "Insert Code Snippet"

 

NS_Editor_9

 

2. A menu will display all available code snippets.

 

NS_Editor_10