NinjaScript > Educational Resources > Tips > User Defined Methods >

Sample 1

Print this Topic Previous pageReturn to chapter overviewNext page

The following sample illustrates two user defined methods within the strategy UserDefinedMethods.cs file. You can add methods or edit methods by:


1. Tools-->Edit NinjaScript-->Strategy... select UserDefinedMethods

2. Add or edit your method

3. From within the NinjaScript Editor, right click and select the menu "Compile"


In the image below, there are two user defined methods as examples:


1. IsMorningSession() method which checks if the bar time is in the morning trading session

2. HigherPrices() method which checks if there are n number of higher prices





The following image illustrates the use of the two user defined methods from above in a custom strategy.