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
Swing Positions
Collapse
X
-
Hello Hamrall,
Thanks for your note.
When you say permanently label a swing, are you drawing text on the chart with DrawText() and this is being overwritten repeatedly?
If so, use a bool that is reset once per bar to prevent the text from being overwritten.
For example:
In #region Variables:
private bool oncePerBar = false;
In OnBarUpdate():
if (FirstTickOfBar == true)
{
oncePerBar = false;
}
if (oncePerBar == false)
{
DrawText("myText"+CurrentBar, "my text", 0, High[0]+4*TickSize, Color.Black);
oncePerBar = true;
}Chelsea B.NinjaTrader Customer Service
-
No not exactly. Using the "Swing" indicator if I were to set say 5 different swings using the instance of 0,1,2,3,4 and try to perform some type of logic say "is swing0 > swing3" it would be fine but if a new swing came then the instances would update by 1 so instance 0 would now be instance 1 and so fourth.
Comment
-
Hello Hamrall,
By default the Swing indicator should only update once per bar (COBC is true by default).
Meaning a new swing should not appear until the bar closes and a new bar opens.
Do you have Calculate on bar close set to false?
Are you finding the Swing is set more than once per bar?
If you want to save the value of the swing, save this to a variable and you will be able to call this value anytime.
For example:
private double savedSwingValue = 0;
savedSwingValue = Swing(5).SwingHigh[0];
Print(savedSwingValue);
Also, keep in mind that the swing sets values historically. So at any time the Swing could change in the historical data. This is just how the swing indicator works.Chelsea B.NinjaTrader Customer Service
Comment
-
I'm trying to save the instance not the double. So I can compare a swing to another swing based on when they occurred(before or after each other). So if I try to get the bar of the second most recent swing I use instance 2 (Swing().SwingHighBar(0,2,CurrentBar) and the most recent is (Swing().SwingHighBar(0,1,CurrentBar). Now if I want to see if the most recent swing is higher than the previous swing and a new swing high comes after the (Swing().SwingHighBar(0,1,CurrentBar) then this swing would now be (Swing().SwingHighBar(0,2,CurrentBar). Hopefully I am explaining this right
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by proptradingshop, 03-21-2024, 09:50 AM
|
5 responses
26 views
0 likes
|
Last Post Today, 05:17 AM | ||
Started by MaupinFinche, Today, 05:08 AM
|
0 responses
5 views
0 likes
|
Last Post
by MaupinFinche
Today, 05:08 AM
|
||
Started by Enkidu, Yesterday, 06:40 AM
|
9 responses
35 views
0 likes
|
Last Post
by Enkidu
Yesterday, 01:11 PM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
309 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
269 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
Comment