if (CurrentBar < BarsRequiredToTrade) { return; } double Highest = MAX (High, 10) [1]; double Lowest = MIN (Low, 10) [1]; if (High[0] > Highest) { EnterLong ("long"); } if (Low[0] < Lowest) { EnterShort ("short"); }
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
Trying to enter a trade after price exceeds the highest high after 10 ticks.
Collapse
X
-
Trying to enter a trade after price exceeds the highest high after 10 ticks.
Like my headline says, I am trying to enter a trade after the price exceeds the highest high from the past 10 ticks but I don't know if my code is actually doing it. Looking at this code, am I accomplishing what I need to?
Code: -
Hello jertrade,
Thanks for your post.
It will be necessary to use prints to verify that the logic you have written is doing what you expect. For example, you would print out values used to evaluate your conditions, like "Highest" to see that it is giving the value you are looking for, and that the logic is updating as you expect it to.
double Highest = MAX (High, 10) [1]; This code is checking the highest high of the last 10 bars, from 1 bar ago. If you are running against a single tick data series, this would mean the highest high of the last 10 ticks, from the previous tick.
If you are trying to check if the highest high of the last 10 bars is exceeded, you could use MAX (High, 10) [0]; and if you want to see if this happens after X number of ticks, you could add a single tick data series, and use that single tick data series to increment an integer to count how many ticks have passed. Then you could trigger logic "after 10 ticks."
Please see our Multi Time Frame and Instruments documentation for a complete walkthrough for creating multi series NinjaScripts.
Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm
Please let us know if we can be of further assistance.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pechtri, 06-22-2023, 02:31 AM
|
10 responses
124 views
0 likes
|
Last Post Today, 12:03 AM | ||
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Yesterday, 08:25 PM
|
||
Started by ScottWalsh, Yesterday, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Yesterday, 07:40 PM
|
||
Started by olisav57, Yesterday, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Yesterday, 07:39 PM
|
||
Started by trilliantrader, Yesterday, 03:01 PM
|
2 responses
22 views
0 likes
|
Last Post
by helpwanted
Yesterday, 07:25 PM
|
Comment