Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Using MAX() for defining entry levels in previous range
Collapse
X
-
You would have to calculate the range on your own, but it sounds like you are most of the way there.
You have the Highest High for the range found using MAX and the High Price Series. You could use MIN and the Low Price Series to get the minimum value for the range.
MIN - https://ninjatrader.com/support/help...inimum_min.htm
You can subtract the low from high to get the difference, and then that difference would represent your range. You can then take multiples of that range and use it with your logic as needed.
We would not be able to provide assistance in giving you exact logic to accomplish your goal, but this direction and should be able to get you started.
Let us know if there is anything else we can do to help.
Leave a comment:
-
Originally posted by NinjaTrader_Jim View PostHello ExNihilon,
Thanks for your post.
Your logic does not look like there would be any issues, but I may suggest the following:- When testing strategy logic, use prints to show you exactly how your conditions are evaluating and if the order methods are getting reached
- MAX(High, 10)[0] will return the highest high from the current bar and going 9 bars back. If you would like the highest high of the 10 bars before the current bar, you will want to use a BarsAgo reference of 1 with MAX i.e. MAX(High, 10)[1]
It is important to understand the difference between Strategy Positions and Account Positions and the Start Behaviors used with NinjaScript Strategies. Please see the documentation below for more details.
Strategy vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
Start Behaviors - https://ninjatrader.com/support/help..._positions.htm
Debugging tips are also linked below.
Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm
Let us know if you have any questions interpreting the debug output.
Thank you Jim,
I did the debug and found the mistake. Unfortunately it is in the logic of my strategy. What I want to do is open a trade if the current price is in the lower or upper 10% of PRICE RANGE (highest price vs lowest price)in defined previous period - 5days,10 days or 20days..
What my previous code did instead was that it took the HIGHEST PRICE in the period and multiplied it by 0,9 which meant the triggering price was immediately 10% lower and so it triggered trades constantly.
So it did not work with the price range but with the highest price.
Now,would you have any advice how to achieve what I want? Is there any function of computing price range, so that I could maybe multiply and get the to the point where the current price is in the upper 10% of the previous price range to go short?
Thank you again.
Leave a comment:
-
Hello ExNihilon,
Thanks for your post.
Your logic does not look like there would be any issues, but I may suggest the following:- When testing strategy logic, use prints to show you exactly how your conditions are evaluating and if the order methods are getting reached
- MAX(High, 10)[0] will return the highest high from the current bar and going 9 bars back. If you would like the highest high of the 10 bars before the current bar, you will want to use a BarsAgo reference of 1 with MAX i.e. MAX(High, 10)[1]
It is important to understand the difference between Strategy Positions and Account Positions and the Start Behaviors used with NinjaScript Strategies. Please see the documentation below for more details.
Strategy vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
Start Behaviors - https://ninjatrader.com/support/help..._positions.htm
Debugging tips are also linked below.
Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm
Let us know if you have any questions interpreting the debug output.
Leave a comment:
-
Using MAX() for defining entry levels in previous range
Hello,
I am trying to do a strategy when you enter the position when the price is at certain % level of the price range of given previous period. - Near highs and lows of the period.
I thought the function MAX() would do that, but the script doesnt work and opens random trades on every bar
the code is as follows:
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 12)
return;
// Set 1
double value = MAX(High, 10)[0];
if (Close[0] >=( value *0.9))
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
.
.
The variable value is defined like this:
private double value;
It should open the trade when the price is in the range of 10% near the high of previous 10 bars.
Thanks for any advice
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
6 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Leave a comment: