can you help me with the region drawing code..... which code I should use from the link you provided for a sma cross....
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
Sma cross strategy
Collapse
X
-
Originally posted by NinjaTrader_ChelseaB View PostHello hir04068,
I've copied the example from the help guide and substituted the SMA.
Code:Draw.Region(this, "tag1", CurrentBar, 0, SMA(7), SMA(14), null, Brushes.Blue, 50);
i used this code
if (CrossAbove(SMA1, SMA2, 1))
{
Draw.ArrowUp(this, "tag1" + CurrentBar, false, 0, (Close[0] + (-3 * (TickSize * 10))) , Brushes.Lime);
Draw.Region(this, "tag1", CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Blue, 50);
}
// Set 2
if (CrossBelow(SMA1, SMA2, 1))
{
Draw.ArrowDown(this, "tag1" + CurrentBar, false, 0, (Close[0] + (3 * (TickSize * 10))) , Brushes.Red);
Draw.Region(this, "tag1", CurrentBar, 0, SMA(PeriodSlow), SMA(PeriodFast), null, Brushes.Red, 50);
}
but i just get blue colour and no red colur when it cross down....
Comment
-
Hello,
I used this code and now its painting 2 color but I think I did something wrong.... can you please chk // Set 1
if (CrossAbove(SMA1, SMA2, 1))
{
Draw.ArrowUp(this, "tag1" + CurrentBar, false, 0, (Close[0] + (-3 * (TickSize * 10))) , Brushes.Lime);
Draw.Region(this, "tag2" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Blue, 20);
}
// Set 2
if (CrossBelow(SMA1, SMA2, 1))
{
Draw.ArrowDown(this, "tag1" + CurrentBar, false, 0, (Close[0] + (3 * (TickSize * 10))) , Brushes.Red);
Draw.Region(this, "tag3" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Red, 20);
}
Comment
-
Hello hir04068,
I see that you have set the tag for the Up and Down arrow to the same, was this intentional? It looks like the other tags used are unique.
This is all I can see that may be incorrect, I also see the Down arrow and Region share the same color where the Up arrow and region do not. Is this related to what you are seeing?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
hello,
I am using this code but I don't get lime color in region area...... can you please chk
thanks
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if ((SMA1[0] + (Close[0] * TickSize)) > SMA2[0])
{
Draw.Region(this, "tag1" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Red, 10);
}
// Set 2
if ((SMA1[0] + (Close[0] * TickSize)) < SMA2[0])
{
Draw.Region(this, "tag2" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Lime, 30);
}
// Set 3
if (CrossAbove(SMA1, SMA2, 1))
{
Draw.ArrowUp(this, "tag3" + CurrentBar, false, 0, (Close[0] + (-1 * (TickSize * 5))) , Brushes.Lime);
}
// Set 4
if (CrossBelow(SMA1, SMA2, 1))
{
Draw.ArrowDown(this, "tag4" + CurrentBar, false, 0, (Close[0] + (1 * (TickSize * 5))) , Brushes.Red);
}
}Attached Files
Comment
-
Hello hir04068,
As a heads up, the file name is SMAregion but the internal name for the script is SMAcross.. which can be confusing.
Are you using prints to ensure that the condition to draw the object is evaluating as true?
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
If a print of the Time[0] is in the same action block of the Draw.Region call that is not appearing, does the time appear in the output window?
If not, print all variables and values used in the condition set to the output window.
May I have the output from the prints to see on what bars the condition is evaluating as true?
Below is a complex script that does region highlighting for multiple moving averages.
Rewrite of the MACrossBuilder 1) Various Moving averages: DEMA, EMA, LinReg, HMA, SMA, TEMA, TMA, VWMA, WMA, ZLEMA 2) Various indication options 3) Can output to alerts window 4) Can output to Market Analyzer (+1, 0, ‐1 = Cross up, No cross, cross down) 5) Colors region between Moving averages V1.02 Update 10‐31‐17, minor code […]
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello hir04068,
As a heads up, the file name is SMA region but the internal name for the script is SMA cross.. which can be confusing.
Are you using prints to ensure that the condition to draw the object is evaluating as true?
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
If a print of the Time[0] is in the same action block of the Draw. Region call that is not appearing, does the time appear in the output window?
If not, print all variables and values used in the condition set to the output window.
May I have the output from the prints to see on what bars the condition is evaluating as true?
Below is a complex script that does region highlighting for multiple moving averages.
Rewrite of the MACrossBuilder 1) Various Moving averages: DEMA, EMA, LinReg, HMA, SMA, TEMA, TMA, VWMA, WMA, ZLEMA 2) Various indication options 3) Can output to alerts window 4) Can output to Market Analyzer (+1, 0, ‐1 = Cross up, No cross, cross down) 5) Colors region between Moving averages V1.02 Update 10‐31‐17, minor code […]
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by FrazMann, Today, 11:21 AM
|
0 responses
1 view
0 likes
|
Last Post
by FrazMann
Today, 11:21 AM
|
||
Started by geddyisodin, Yesterday, 05:20 AM
|
8 responses
51 views
0 likes
|
Last Post Today, 10:45 AM | ||
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
10 responses
36 views
0 likes
|
Last Post Today, 11:10 AM | ||
Started by DayTradingDEMON, Today, 09:28 AM
|
4 responses
24 views
0 likes
|
Last Post Today, 10:47 AM | ||
Started by George21, Today, 10:07 AM
|
1 response
17 views
0 likes
|
Last Post Today, 10:43 AM |
Comment