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 no trader
Collapse
X
-
crossover strategy no trader
Hi ninjatraders, I made an indicator plot, and when price crosses below it and it's an up bar I go long, when price crosses above it and it's a down bar I go short. I made another indicator that draws arrows on these signals. The picture shows this on a 4 range chart. The problem is that live the arrow indicator stops plotting and the prints no longer show the condition is being met. However, historically on the chart you can see the condition being made, and it also works in backtest. Could the solution be something simple I'm missing? Also I'm using cobc= trueLast edited by sampras010; 01-29-2018, 09:12 AM.Tags: None
-
Hello sampras010,
Thanks for opening the thread.
Without the code and testing on my end, I am only left to guess at what the issue may be. I would expect COBC=true to work consistently between historical and realtime data.
Are you saying that there are arrows that aren't plotting in realtime, but if you reload the NinjaScript with F5, the arrows appear?
If you have identified that the arrow is not drawing because conditions are not becoming true, we would have to take a closer look at what is going into the condition so it results as false. When you add prints for the values going into the condition, do you get any hints as to how the condition may need to be changed?
Please provide a reduced example of the condition and the prints you have made if you have been unable to resolve your inquiry.
I look forward to being of further assistance.JimNinjaTrader Customer Service
-
I tried this...
Code:if (CrossAbove(Close, PLOT(), 1) && Close[0]<= Close[1]) { Print(Time[0]); EnterShort(1,"Short"); SetStopLoss(330); } if (CrossBelow(Close, PLOT(), 1) && Close[0]>= Close[1]) { Print(Time[0]); SetStopLoss(330); EnterLong(1,"Long"); }
Code:if(Close[0] < PLOT()[0] && Close[0] >= Close[1] && Close[1]>= PLOT()[1] ) { Print(Time[0]); EnterLong(); SetStopLoss(330); } if(Close[0] > PLOT()[0] && Close[0] <= Close[1] && Close[1]<= PLOT()[1] ) { Print(Time[0]); EnterShort(); SetStopLoss(330); }
Comment
-
Hello sampras010,
Thanks for your reply.
When you print out the values that create the condition, what do you see? For example, Close[0], PLOT()[0], Close[1], PLOT()[1].
This may give hint to look further into the indicator that creates the plot value. I may also suggest testing with a system indicator like an SMA to verify the issue has to do with an underlying indicator's logic.
I'm happy to be of any additional help.JimNinjaTrader Customer Service
Comment
-
ok, so I used this print in realtime
Code:Print(Time[0]+" - Close[1]: "+Close[1]+" > PLOT()[1]:"+PLOT()[1]+" - Close[0]: "+Close[0]+" < PLOT()[0]:"+PLOT()[0] );
9:02:54 AM - Close[1]: 65.26 > PLOT()[1]:65.225 - Close[0]: 65.29 < PLOT()[0]:65.225
historically I got this
9:02:54 AM - Close[1]: 65.26 > PLOT()[1]:65.225 - Close[0]: 65.29 < PLOT()[0]:65.3
Could it be that the plot isn't fast enough in realtime to be registered in time? Just watching the chart, it seems to plot at each close of a bar on time. Would I need to use cobc = false for a portion of the strategy?
Comment
-
Hello sampras010,
If the indicator is using the same data series as the input series, and is not calculating off another data series, I would expect the output to be the same for COBC=true.
Can you confirm if you are seeing the same behavior using a system indicator like an SMA?
Are you also seeing this behavior with other instruments?
This will tell us if we need to try an instrument reset or look further into the PLOT() indicator to see why its output is different.
I look forward to being of further assistance.JimNinjaTrader Customer Service
Comment
-
I'm not sure what you mean. The Plot() indicator is just another instruments price. I added range bars and plotted them with Plot0.Set(Closes[1][0]).
So correct me if I'm wrong, with COBC= true on every close of the instrument I'm charting, the last closed bar of the instrument comprising the plot() indicator should be known, plotted, and should be available for comparison at that time? This is what I'm seeing watching the Plot() indicator.
I tried with an SMA (wasn't able to make the same exact conditions possible) but for a simple crossover an indicator in realtime works.
As for other instruments, I'm not sure if the condition is ever true for them so I'm not sure.
Comment
-
Hello sampras010,
So correct me if I'm wrong, with COBC= true on every close of the instrument I'm charting, the last closed bar of the instrument comprising the plot() indicator should be known, plotted, and should be available for comparison at that time? This is what I'm seeing watching the Plot() indicator.
With the indicator's plot using the the value of the previous bar, I am suspicious that the plot value is being set on a different BarsInProgress than the primary series. BarsInProgress checks to make sure that the plot value is set on the primary data should make sure that the results are consistent.
If this information does not resolve your inquiry, could you export the indicator with a calling NinjaScript (strategy or indicator) so we may see the full scope of the issue on our end to give further advise?
Exporting - https://ninjatrader.com/support/help...nt7/export.htm
I've also linked the Multi Series NinjaScript documentation for reference when using BarsInProgress and working with Multi Series NinjaScripts in general - https://ninjatrader.com/support/help...nstruments.htm
I'm happy to be of further assistance.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
55 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
3 responses
9 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by jordanq2, Today, 03:10 PM
|
2 responses
8 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
47 views
0 likes
|
Last Post Today, 02:36 PM |
Comment