Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
To make a standard Fib setting as part of script
Collapse
X
-
Tags: None
-
Hello trdninstyle,
If you don't want the user to be able to modify the settings, custom render the lines and shapes in OnRender() instead of calling a Draw method().
You can set the IsLocked property, but this only prevents the object from being moved, but does not prevent the user from changing the settings.Chelsea B.NinjaTrader Customer Service
-
Wow this was very interesting Chelsea, I need to learn this so I'll delve into it tonight.
I was thinking to have the Fib, only 100% ext now, to brush the same color that is selected for the bar color, so it matches.
In the meantime I added the fib in with the draw method. Thank you for the quick response, you are busy.
Comment
-
I'll need more time to learn custom render and how to apply this function to my script. I imported the example you provided & looked at it, I don't know how to apply it to my script yet or enough to tinker with it. I do like it, it will be easy once I can understand it. Would you have anymore examples how I could apply rendering to my fib?
With what I have now with Draw method I do understand, what I'm trying to attempt right now would be to allow the user to select a lookback option or not (true or false) for the Fib.
Here's my attempt, I have the three parts to it.. I realize I can't really use convert to string the way I have it but it's my starting point.
ConvertToString(CurrentBars[0]) = true;
*******************
if ((Close[2] > Open[2])
&& (Close[1] > Open[1])
&& (Close[0] > Open[0])
&& (Close[2] > High[3])
&& (Close[1] > High[2])
&& (Close[0] > High[1])
&& (Low[1] > Low[2])
&& (Low[0] > Low[1])
&& ConvertToString(CurrentBars[0]) == true)
{
Draw.FibonacciRetracements(this, @"ColorBars Fibonacci retracements_1"+ Convert.ToString(CurrentBars[0]), false, 2, Open[2], 0, Close[0], false, "1RTarget");
}
*******************
[NinjaScriptProperty]
[Display(Name="+ Convert.ToString", Description="Save a Fib template that you want: Name it ThisFib", Order=4, GroupName="Parameters")]
public bool ConvertToStringCurrentBars
{ get; set; }
Also, I'm calling my draw method to brush 3 bars after a condition but when the condition continues beyond the 3 bars it brushes those too. How do I program it to stop after 3 bars? I tried with null various ways.
Thank you ChelseaLast edited by trdninstyle; 11-27-2024, 12:18 PM.
Comment
-
Hello trdninstyle,
"Would you have anymore examples how I could apply rendering to my fib?"
This would be an indicator rendering lines at the same price and time of where the fibonacci drawing tool price level would be. This would not be in the drawing tool script, but would be done from the indicator..
The user would not be able to move or adjust a line or shape rendered in onrender from an indicator.
"With what I have now with Draw method I do understand, what I'm trying to attempt right now would be to allow the user to select a lookback option or not (true or false) for the Fib."
A look back option how?
Can you clarify what this means?
Do you want to remove drawing objects if they were drawn with an anchor more than the select number of bars ago?
"Here's my attempt, I have the three parts to it.. I realize I can't really use convert to string the way I have it but it's my starting point."
How are wanting to use the bar number as a string?
Is this so the tag name is unique so new objects are drawn?
"MyTagName" + CurrentBars[0]
CurrentBar and CurrentBars[0] provides an integer number of the currently processing bar. This is not a true or false value...
A true or false value is not a string..
ConvertToString(CurrentBars[0]) == true
What are you trying to compare with this line of code in the condition?
"Also, I'm calling my draw method to brush 3 bars after a condition but when the condition continues beyond the 3 bars it brushes those too. How do I program it to stop after 3 bars? I tried with null various ways.
I'm not clear on what this means.
A brush is a color object. A brush would be used as the color a line or shape..
For example if Brushes.Orange is supplied to Draw.Dot, the dot will be orange.
Draw.FibonacciRetracements() has a PriceLevels property. Each PriceLevel has a Stroke which holds the brush.
Are you asking how to set lines to transparent after 3 bars?
Are you not asking about brushes at all but asking how to not call Draw.Retracements() after 3 bars in the logic?
Chelsea B.NinjaTrader Customer Service
Comment
-
Thanks Chelsea,
Yes, on the rendering, those lines (same as fib the lines) would be supplied in the indicator itself (thats what I like about it) but I'm putting that aside until I can grasp it a little better.
***************
"A look back option how?"
Right now I have it so the user can select whether to use the fib drawing or not but right now it shows it for the whole historic lookback when they select to use the fib. I want an additional option to use that historic lookback (for review) or just the most recent fib drawing & not clutter the chart with fibs going all the way back. (Thats fine for study)
***************
Yes, this is more along the lines what I was attempting (below)
"Is this so the tag name is unique so new objects are drawn?"
"MyTagName" + CurrentBars[0]
If a user selects Fib it draws a fib every time a new condition occurs but not in the lookback unless he selects that too.
(I know a string isn't a bool & I was applying a string as a bool, like I said, I knew it was wrong)
*********************
"I'm not clear on what this means."
I said it wrong, BarBrushes = MyBrush I was just referring to the color of the bars & I was saying brush.
You see, I'm calling it to color the first 3 bars when certain conditions apply, but when those conditions continue for a bar or more it colors those too.
I'm wanting to just BarBrush the first 3 bars & no more.
{
BarBrushes[0] = MyBrush;
BarBrushes[1] = MyBrush;
BarBrushes[2] = MyBrush;
}
Thank you for helping me to understand better, the rendering may take a minute, I'll double back to that later. That would be very cool to have my lines like that in that sample.
Last edited by trdninstyle; 11-27-2024, 01:30 PM.
Comment
-
Hello,
"Right now I have it so the user can select whether to use the fib drawing or not but right now it shows it for the whole historic lookback when they select to use the fib. I want an additional option to use that historic lookback (for review) or just the most recent fib drawing & not clutter the chart with fibs going all the way back. (Thats fine for study)"
"If a user selects Fib it draws a fib every time a new condition occurs but not in the lookback unless he selects that too."
Are you trying to ask how to not call a Draw method when State is State.Historical?
"You see, I'm calling it to color the first 3 bars when certain conditions apply, but when those conditions continue for a bar or more it colors those too.
I'm wanting to just BarBrush the first 3 bars & no more."
Add an int variable as a counter. In State.DataLoaded set the value to -1.
In your branching command logic block set the value of the int variable to 0.
In another condition compare the int variable to be greater or equal to 0 and less than 3.
When true, trigger the action and increment the variable by 1.
In an else if compare the variable to be equal to 3 and then set the variable to -1.
private int counter;
counter = -1;
if (/*condition to start setting BackBrush*/)
{
counter = 0;
}
if (counter >= 0 && counter < 3)
{
BackBrush = Brushes.Orange;
counter++;
}
else if (counter == 3)
{
counter = -1;
}Chelsea B.NinjaTrader Customer Service
Comment
-
"Are you trying to ask how to not call a Draw method when State is State.Historical?"
Yes, to have a fib draw historical only if he selects it, otherwise it just draws a fib occurrence by occurrence.
Thank you for showing me how to stop additional bars from coloring outside of 3 bars, I'll work on this tonight.
Comment
-
-
Yes, just like any true false action for the draw method you put it in the branch command. Thanks you very much.
Comment
-
Hoping you had a good Thanksgiving,
if ((State == State.Historical && MyAllowHistoricalActionsInputBoolNameHere == true) || State == State.Realtime)
{
// trigger action
}
Here are my screenshots of the action I took from these instructions, I'm sure I did not do it completely correct.
Thank you for your time Chelsea.
************************************************** ***********************************
I must have placed all of these in there correct places.
I know it says BackBrush which paints the background which tells me I got it correct, the placements.
What I want to do is not paint the bars or background after 3 bars when the same conditions continue after the 3 bars.
private int counter;
counter = -1;
if (/*condition to start setting BackBrush*/)
{
counter = 0;
}
if (counter >= 0 && counter < 3)
{
BackBrush = Brushes.Orange;
counter++;
}
else if (counter == 3)
{
counter = -1;
}
Here's my chart with 4 bars getting colored, I want to eliminate that 4th bar from the equation, and beyond that if conditions persist.
Next post, over limit.
Last edited by trdninstyle; 11-29-2024, 08:26 AM.
Comment
-
-
Hello trdninstyle,
It looks like you are calling Draw.FibonacciRetracements() twice in the code.
One is going to be called on every real-time bar update as long as FibLookBack is true. The other is called with your custom condition.
You've used the same tag name on both method calls, so the object will be updated instead of a new object drawn.
The condition code I suggested, I was suggestion you could add to your existing condition.
"You can choose to add these conditions to the branching command that calls the Draw method."
With the counter, your condition is not checking the value of the counter.
It doesn't matter what the counter value is, the condition doesn't compare it to be less than 4.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment