Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I think your issue may be that you have the same draw tags overwriting each other. Make each draw tag unique. If you need to place text on multiple bars and you're generating no more than one text object per bar, then one way to make sure your tags are unique is to use CurrentBar in constructing your tag.
Ex:
Draw.Text(this,"DT_"+CurrentBar,false, … the rest of your code
If you need more than one text object per bar, then use "DT1_"+CurrentBar, "DT2_"+CurrentBar, so on and so forth.
If you keep using the same draw tag with successive calls to Draw.Text() on different bars, each time the function is executed, it will operate on the same text object instead of generating a new text object for the new bar. Which means the older text will disappear and get replaced with the new text at the new location. If I'm not mistaken, this is what you're seeing.
Hope this is clear.
Good luck.
Can you help answer these questions from other members on NexusFi?
@sg72 Thank for the info. I have experimented with tags and that does not appear to make
a difference. When I use the two instances of the Draw.Text not only does the desired text not
appear but all output from the indicator ceases as well.
It just occurred to me that you're trying to place your text several bars back. When you loop through the logic inside OnBarUpdate(), that goes through all the bars on the chart starting with the first bar that prints. If for example, OnBarUpdate() happens to be on bar #5 from the beginning and you're trying to place a text 15 bars ago, you're going to get an indexing error. If you haven't don't so already, please open a NinjaScript Output window and watch for errors/warnings there. That might give you a clue as to what's happening.
If this is the issue you're having, you can get around it by having a statement like below so that you'll skip over the logic for the first few bars until you have enough bars that if you attempt to go back a few, it won't give you the indexing error.
protected override void OnBarUpdate()
{
if(CurrentBar < 10 ) { return ; } // Skip the first few bars to let things settle down.
The rest of your logic here
}
Thanks for that, I actually have that test in my code, I had not included it here for clarity.
Thanks for the input but that does not seem to be the issue.
If you'd like, you can copy the relevant parts of your code into a shorter script and test to make sure it has the same issue and then attach it here and I'll look at it and see if I can figure out what the issue is. Without seeing the code, I'm running out of ideas as to what it could be.
I agree it is your tag. They need to be unique. However using CurrentBar will give you more than two bits of text. Not sure if that is your intention. If not just use two unique Tags.
for (int i = 0; i < row; i++) output += "\r";
output += txt;
Draw.TextFixed(this, tag, output, textPosition, myBrush, myFont, Brushes.Transparent, Brushes.Transparent,
opacity);
}
protected void RenderTextInfo()
{
// This next line draws the box and I use I put \r for each line
Draw.TextFixed(this, "Box","l l\r\r\r\r\r\r\r\r", TextPosition.TopLeft,
Brushes.DarkOliveGreen, myFont, Brushes.DarkOliveGreen, Brushes.Black, 85);
DrawTextFixed(TextPosition.TopLeft, 1, "ATR", String.Format("ATR: {0:0.00}", myATR[0]),
Brushes.Yellow);
// And so on for other lines
}