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
Setup indicator
Collapse
X
-
Setup indicator
Hi guys, I'm developing a new indicator, it's an average HILO crossover crossover, when the retr occours (on the lower avg) with close>previous bar then setup is confirmed. As you can see in the attached image, setup is marked with a "lime" bar, but it's wrong. I did many tests, but nothing to do. May someone help me coding better this indicator?
Tags: None
-
imported post
To debug, have you tried sending data to the Output Window (Print) and traced the following information:
CurrentBar
BarTime
Data points used to trigger the condition
This is what I do to give me an idea what the conditions are when the bar is changing to lime.
Is this chart you provided real-time or historical? Meaning, does the indicator behave correctly on historical data but the error only shows up in real time?
Ray
RayNinjaTrader Customer Service
-
imported post
Thank Ray, I'm trying nt6beta (demo) with globalfutures, realtime eminis (the same occours with historical data). Sorry for the past message, I forgot to attach the code! attached datawindow image. Thanks
Code:{ #region Variables // Wizard generated variables private int leng = 89; // Default setting for Leng private DataSeries diff; private int brk = 0; private bool retr ; private bool retr2 ; private bool HiLo ; private bool HiLo2 ; #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = true; diff = new DataSeries(this); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { diff.Set (TickSize); // double diff = High[0] - Low[0]; double MaCl = Low[0]; double MaCl2 = High[0]; double MaCl3 = Close[0]; double MaHi = HMA(High,Leng)[0]; double MaLo = HMA(Low,Leng)[0]; double offset = HMA(diff, Leng)[0]; double tlrnH = MaHi + offset; double tlrnHH = MaHi - offset; double tlrnL = MaLo - offset; double tlrnLL = MaLo + offset; if (CrossBelow(Close, MaLo, 1)) HiLo = false; retr = false; if(HiLo == true ){ if ((MaCl >= (tlrnL) && MaCl <= (tlrnLL)) && MaCl3 > MaLo) retr = true; else retr = false; //} if (retr == true && (Close[1] <= Open[1] && Close[0] >= Open[0])) BarColor = Color.Lime; } if (CrossAbove(Close, MaHi,1)) HiLo = true;
Comment
-
imported post
Thanks. So looks like the "retr" variableisnot being set based on your expectations.
What I suggest is adding a Print Statements such as:
Print(Time[0].ToString() + " 1" + retr)
Print(Time[0].ToString() + " 2" + retr)
Print(Time[0].ToString() + " 3" + retr)
Print(Time[0].ToString() + " Final" + retr)
Place the first three at the exact spots where you set the "retr" variable and the last one at the very end of the OnBarUpdate() method. Then look in the OutPut window to determine why the "retr" is not set to false at the lime bar is incorrect.
Ray
RayNinjaTrader Customer Service
Comment
-
imported post
I can't tell you where its wrong but its obvious then that the condition should be false when it is true. What I would do next is determine visuallly what bar on the chart should trigger the condition to be false and write and place more print statements to see what the logic flow is for that bar, print out value to see where you have a logic flaw in your code.
Ray
RayNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by carnitron, Today, 08:42 PM
|
0 responses
2 views
0 likes
|
Last Post
by carnitron
Today, 08:42 PM
|
||
Started by strategist007, Today, 07:51 PM
|
0 responses
3 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,969 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
5 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
Comment