This script is inspired by John Ehlers works on using DSP for trading. His books and articles contain formulas that estimate lag for some indicators. However, how to estimate lag in general case?
This script uses the DFT Phase Response (PhR) to make this estimation. The negative shift in the PhR pushes the values to the right, thus delaying the signal. The raw PhR returns the angle value. However, we want to estimate lag in terms of bars (time delay). To do it, we need to take an account the frequency (or period) of the phase:
I built this little tool to help reset my _WorkSpace.xml file.
Example of use:
Upon coding an indicator you forget to dispose of a resource so when pressing F5, NT8 crashes. The problem is NT8 will reload that last workspace....only to crash again....and again. You want to restart with another workspace loaded so you can fix the problem, right?
Well, the old and tedious way is to open your _WorkSpaces.xml file, search for OpenWorkspaces and delete the entries, replacing them with one/some default templates. After doing this a hundred times...I decided enough is enough
(I believe you can safe load NT8 to do a similar job, but I like the flexibility of choosing my own workspaces to load.)
When NT8 is closed just run the .exe file and drag and drop which workspaces you want to load up upon the next restart. Instructions are inside the zip file. Do not import into NinjaTrader!
If you wish to see inside the .exe file just use any decompiler like DotPeek.
March 9th, 2017
Size: 34.18 KB
Downloaded: 566 times
1840
Sim22
Description:
This algorithm is a custom performance index for the Default or Genetic optimization methods in NinjaTrader 7. Optimization with this index maximizes the 20th percentile of noise-injected bootstrapped expectancy. This metric is designed for robustness against worst case conditions. Note that due to the mathematics, the solution is not deterministic (run it multiple times, and you will get slightly different solutions each time).
Installation:
Add this file to your ...\NinjaTrader 7\bin\Custom\Type\ directory, open any indicator or strategy, and compile.
Details (this math is in here):
1. For a given series of trades of length N, the top 10% are removed, creating a modified series of trades of length N*0.9.
2. This modified series of trades is sampled *with replacement* for 10*N*0.9 samples. This series becomes the bootstrapped trade series.
3. Gaussian noise is a given mean and standard deviation is added to each bootstrapped sample.
4. Expectancy for this bootstrapped + noise series is calculated.
5. Steps 2 through 4 are done 5000 times, with different sampling from the Gaussian noise. This creates a distribution of expectancy.
6. Finally, the performance index returns the 20th percentile of these 5000 runs (so, the 1000th worst expectancy) to the NT optimizer.
Discussion:
Removal of the 10% best performing trades is an attempt to be pessimistic by assuming that the best 10% trades observed in the past will never repeat. We do not want total system performance to hang a few high-yielding trades.
Injecting noise to the bootstrapped sample accomplishes two things. First, it adds uncertainty to each bootstrapped series, thereby simulating diversity in the bootstrapped series (hopefully the diversity we would measure in a much larger sample). Secondly, it makes each bootstrap series unique. This means that we way calculate a distribution from the ensemble of bootstrapped series.
Any percentile may be returned. We could return the mean. By returning a value to the left of the mean, the 20th percentile, we are maximizing 80% of the distribution.
Note: Because we are injecting randomly sampled noise to the bootstrapped series, the solution from this performance index is not deterministic!
Suggestions:
If you use this, you should be comfortable changing the parameters found at the top of the algorithm. Adjusting the value of the standard deviation of the noise may make or break the robustness and success of this algorithm.
Note: If you find bugs, have feature requests, or anything else, post in THIS thread.
This is a simple indicator that allows you to plot the day of the week name on the sessions bar's start. You can name the days whatever you want(Mon,Monday,M), by manipulating the "Day Names" section.
If the day isn't labeled the way you want... E.g., the first session on a Forex template is Sunday, but if I want it to say "Monday," you can input "Monday" in the "Day1" text field.
This indicator works onEachTic, and will work on Daily and Intraday charts.
This indicator was created from specs in THIS post.
NOTE: Installing this indicator will create a folder called "BTMM," that's where the indicator will be.
---EDIT - V2 3March2022---
Adding an input, so that you can affix the labels to the BOTTOM of the chart.