Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calculating % change in price over period
Collapse
X
-
Originally posted by NT-Roland View Post
-
Hi Lowerlevel1,
The StrategyBuilder (SB) is not really designed for more advanced calculations. However, the coding challenge you described can still be managed in the SB if you really push it to its limit.
Consider to add Custom Series in SB. This trick will allow you to perform divisions of custom values in SB !!!
Initiate/Update these Custom Series as needed. Don't forget to reset them back to zero from time to time (e.g. every day) and then start over. Otherwise, you will get only very few trades.
DeltASeries[0] = HighASeries[0] - LowASeries[0]
DeltBSeries[0] = HighASeries[0] - LowBSeries[0]
PercentSeries[0] = DeltBSeries[0] / DeltASeries[0].
That division is the critical part. Once you have this, the rest is easy.
You could compare the PercentSeries to some sort of threshold (e.g. Input MinPercent), etc., and then fire off your trades.
Print to Output Window could look like the attached (NQ 12-2020, 60 Min), with daily reset of all vars/series on the first bar.
Have fun.
NT-RolandLast edited by NT-Roland; 10-25-2020, 05:00 PM.
- 1 like
Leave a comment:
-
Hello Lowerlevel1,
The Strategy Builder is not capable of math in any place other than with offsets.
For custom math, the strategy would need to be unlocked and coded by hand.
Are you wanting the percent from the high to the low as a percent of the high?
((High[0] - Low[0]) / High[0]) * 100
Are you wanting the percent change from the previous bar?
((Close[0] - Close[1]) / Close[0]) * 100
Leave a comment:
-
Calculating % change in price over period
First, full disclosure, I'm new to programming and working to have a better understanding of it, and frankly maybe a bit in over my head, but I'm determined to figure this out. So I want to say thank you in advance to anyone that can help.
That being said, I want to build a strategy based on a percent change in price in a given range. Whereas I'm looking for a reversal in price in a given area based on Fibs. That being said, my first order of business is to calculate the percent change in price, however, I'm not really seeing how I can accomplish this in the strategy builder itself.
My approach has been to identify the low and high over a period of bars and record these values into a variable. Where such I was hoping to calculate the percentage change of a new low or high of the retracement, be it a long or short against the original distance of the low and high. Mathematically, the formula would be High - Low_a = X; X - (High - Low_b) / X = Y; Y x 100 = % change. But again, I'm not seeing how to accomplish this within the strategy builder.
ie. Low = 1606.1, High = 1614.3, Low_b = 1609.9
1614.3 - 1606.1 = 8.2
1614.3 - 1609.9 = 4.4
(4.4 / 8.2 = 0.537)*100 = 53.66%
I've searched youtube and this forum for similar discussions, however, I've not been able to find anything. Any help, and or direction would be appreciated.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by voltation, Today, 04:32 PM
|
1 response
8 views
0 likes
|
Last Post
|
||
Started by coopgrafik, Today, 03:44 PM
|
2 responses
23 views
0 likes
|
Last Post
![]()
by coopgrafik
Today, 04:20 PM
|
||
Started by cionjay, Today, 02:36 PM
|
1 response
9 views
0 likes
|
Last Post
|
||
Started by onnb1, Today, 02:08 PM
|
1 response
10 views
0 likes
|
Last Post
|
||
Started by omermirza, Today, 01:15 PM
|
4 responses
20 views
0 likes
|
Last Post
![]()
by omermirza
Today, 03:26 PM
|
Leave a comment: