I have an indicator that draws rays from specific similar candlesticks. The program gets bogged down when a lot of rays are drawn. Is it possible to limit the rays that are drawn to the ones that are within say 5% of the current closing price? So I'd use an "if" and a "Remove DrawObjects" but the ray is drawn from anchor points many bars ago. So how would I determine the rays with current positions within 5% of the the current bar?
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
Limiting the DrawObjects
Collapse
X
-
Limiting the DrawObjects
Hi,
I have an indicator that draws rays from specific similar candlesticks. The program gets bogged down when a lot of rays are drawn. Is it possible to limit the rays that are drawn to the ones that are within say 5% of the current closing price? So I'd use an "if" and a "Remove DrawObjects" but the ray is drawn from anchor points many bars ago. So how would I determine the rays with current positions within 5% of the the current bar? -
Hi stockgoblin,
Yes, this is possible although unfortunately we cannot offer a custom coded solution. If you need to expose values about a drawing object, can use IDraw interface.
You can expose easily the anchor points of a ray:
Exposing Y value at last bar is a little trickier. I show one approach in this manual alert indicator:
Ryan M.NinjaTrader Customer Service
-
Nice, thanks. I'll try to merge line alert with my custom indicator. At first glance it looks like I'll just need to RemoveDrawObject if lineValueAtLastBar is over 5% away from Close. Wish me luck. I'm sure I'll be asking you more. Stay tuned.
Comment
-
Hi,
I'd like to remove all programmed rays outside of 5% below or above the last bar.
I'm thinking I can just modify the LineAlert Indicator as follows:
THIS:
//Alert Checking is done here. Can add your own actions to the block if desired.
if(CrossBelow(Close, lineValueAtLastBar, 1) || CrossAbove(Close, lineValueAtLastBar, 1))
{
Alert("AlertLineCrossing", Cbi.Priority.High, alertMessage, soundFile, 0, Color.White, Color.Black);
}
TO THIS:
//Alert Checking is done here. Can add your own actions to the block if desired.
if(lineValueAtLastBar > Close[0] * 1.05 || lineValueAtLastBar < Close[0] * .95 )
{
RemoveDrawObjects();
}
This just removes all the rays. How do I refer to just the last bar?I can't use Close[0] because the indicator goes through all the data bar by bar. Do I have to make the lookback period set to 1 or something like that?
Comment
-
This part may be tricky, because you need to be able to pass in the tag of the drawing object into RemoveDrawObject(). That's the method for removing a single object
If you structure all your rays as objects with IRay, then you can expose, and reference the tags. A foreach loop can also go through all drawing objects in the collection.
Using the structure from the Alert script, you may (untested) be able to do something like:
if (lineValueAtLastBar > Close[0] * 1.05 || lineValueAtLastBar < Close[0] * .95 )
{
RemoveDrawObject(draw.Tag);
}Last edited by NinjaTrader_RyanM1; 08-14-2011, 07:24 PM.Ryan M.NinjaTrader Customer Service
Comment
-
Hi Ryan,
I'm still having trouble modifying the Line Alert Indicator to recognize programmatically drawn lines. I removed the If Userdrawn line but it didn't seem to do much. Any suggestions.
Comment
-
RemoveDrawObject will work only for manually drawn lines, or for lines programatically drawn by a specific indicator instance. You will not simply be able to use LineAlert for removal only -- You will have to draw and remove in the same script. Most of the tougher concepts should be in the LineAlert indicator, so you may be able to adapt by moving your drawing statements there, and of course removing the check for .UserDrawn.Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Brevo, Today, 01:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
241 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
Comment