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
Crossover Strategy Error
Collapse
X
-
Hello dmking,
Thank you for your reply.
Was this an image of a historical test? If so, the result looks to be about what I would expect based on how historical bars are processed.
For example, the first entry shown I can see the cross visually appears 1 bar before the entry and then we see the entry the next bar after the bar where the signal is processed. In real-time, using OnEachTick would allow the cross condition to be evaluated in realtime so the entry could instead be within the same bar.
Print's are a useful tool to output data to the output window, if you are using the strategy builder how you are currently visualizing the indicators would also be fine. In manual programming, you could also use prints to output the time and if the condition was true or not, etc..
I look forward to being of further assistance.
Leave a comment:
-
Jesse, Take a look at this, I understand what you're saying, but it still looks like the signal occurs later than I would like even with Calculate = On Each Tick. I know that you're busy, but this is just a heuristic for understanding the Strategy Builder within NT8, so this is not urgent. Thanks for you time, patience and help. Dennis
Code:]#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.Indicators; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds strategies in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Strategies { public class Lynx_LE_TriggerTrader : Strategy { private HMA hmaFast; private HMA hmaSlow; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDes criptionSampleMACrossOver; Name = "Lynx_LE_TriggerTrader"; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = true; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; // OrderFillResolution = OrderFillResolution.High; OrderFillResolutionType = BarsPeriodType.Minute; OrderFillResolutionValue = 1; Slippage = 0; StartBehavior = StartBehavior.ImmediatelySubmit; TimeInForce = TimeInForce.Gtc; TraceOrders = false; RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 20; Fast = 8; Slow = 21; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = false; } else if (State == State.DataLoaded) { hmaFast = HMA(Fast); hmaSlow = HMA(Slow); hmaFast.Plots[0].Brush = Brushes.Red; hmaSlow.Plots[0].Brush = Brushes.Cyan; AddChartIndicator(hmaFast); AddChartIndicator(hmaSlow); } } protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) return; if (CrossAbove(hmaFast, hmaSlow, 1)) EnterLong(); else if (CrossBelow(hmaFast, hmaSlow, 1)) ExitLong(); } #region Properties [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)] public int Fast { get; set; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "NinjaScriptStrategyParameters", Order = 1)] public int Slow { get; set; } #endregion } }
Leave a comment:
-
Hello dmking,
Thank you for your reply.
The chart markers can be changed in the charts Data Series window, when you configure the data series you can choose both the color of the markers and if they should be shown.
The cross signal would already work as you want, but this depends on the Calculate setting being used and your condition. If you are using OnBarClose, the calculation is checked at the end of the bar, if true it would be submitted at that point. Otherwise, if you use OnEachTick, the condition could become true intrabar or right after the tick that caused it to become true. If the signal is happening 2 bars past when you think it should have, that may just be a confusion between what you are looking at versus what the strategy is actually using. A Print is most commonly the best way to address this type of comparison to see what values the strategy is actually using at that point in time.
I look forward to being of further assistance.
Leave a comment:
-
Thanks for the response Jesse. I get it. I have another couple of questions:
1. How do I change the color of the arrows from Blue for entry and Magenta for exit?
2. How do I have the signal for entry or exit occur at the instant a cross occurs or the very next bar at the most (Looks like the signal is given 2 bars later)?
Hope this is clear.
D
Leave a comment:
-
Hello dmking,
Thank you for the post.
The error indicates that your script is using a second series in its code, have you used AddDataSeries in your code? If so, the error would be accurate, you already have a secondary series to add fill resolution that can be used.
I look forward to being of further assistance.
Leave a comment:
-
Crossover Strategy Error
Hi I created a simple Crossover Strategy to Understand how strategies work in NT8. I get the following error:
"''High' Order Fill Resolution is only available for single-series strategies. For multi-series strategies, please program directly into your strategy the more granular resolution you would like to simulate order fills with."
The strategy uses a fast and slow MA. Can someone tell me what this error means and how to fix it.
TIATags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
148 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,283 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Leave a comment: