Code Snippets
Previous Topic  Next Topic 

Code Snippet Shortcuts

You can quickly add commonly used methods and code structures via




Via 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);



Via mouse or pressing the "F2" key:


Right click on the NinjaScript Editor and select the menu "Insert Code Snippet"



A menu will display all available code snippets.