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
Addchartindicator() and calculate on tick
Collapse
X
-
Hello Rogue_Two,
Thanks for your post.
The added indicator will adopt the host's calculate mode. Please see tip#3 in the help guide page: https://ninjatrader.com/support/help...?calculate.htm
You can accomplish your goal by setting your strategy to Calculate.OnEachTick and then recode your strategy to only run when IsFirstTickOfBar is true to continue running the strategy once per bar. The help guide has an example of separating your code to run on each tick and on each bar within the same script: https://ninjatrader.com/support/foru...y-tick?t=19387Paul H.NinjaTrader Customer Service
- Likes 1
-
I changed the calculate mode to "Calculate.OnEachTick" and now the indicator I added via AddChartIndicator is now calculating on tick, which is what I wanted.
Now, I am trying to get the triggers to "Calculate on bar close" and after looking through the links you posted I tried this:
Code:// Overbought if (IsFirstTickOfBar) { if (CrossBelow(StochRSI1, Overbought, 1)) { EnterShort(Convert.ToInt32(OrderQuantity), ""); myBelowNeutral = false; } if (Position.MarketPosition == MarketPosition.Short && StochRSI1[0] < Neutral) { myBelowNeutral = true; } if (Position.MarketPosition == MarketPosition.Short && myBelowNeutral == false && CrossAbove(StochRSI1, Overbought, 1)) { EnterLong(Convert.ToInt32(OrderQuantity), ""); } }
Comment
-
Hello Rogue_Two,
Thanks for your post.
There is not enough information posted for me to assist in where the errors are. You can use the compile error information to identify the line and then based on the line what variables are declared as that will usually answer the questions of double verses bools. Also, make sure the errors are indeed for the script you are working on, check the file name column on the left of the errors.
Once the compile errors have been cleared, I recommend adding print statements to your code so you can evaluate what the variables are using in the conditions. Here is a link to our trips on debugging: https://ninjatrader.com/support/help...script_cod.htm
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by brunoviveiros, 02-17-2020, 05:31 AM
|
4 responses
63 views
0 likes
|
Last Post Today, 06:25 AM | ||
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
8 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
11 views
0 likes
|
Last Post Today, 02:34 AM |
Comment