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
Help programmazione
Collapse
X
-
Hi Italy,
Unfortunately, I cannot debug this for you.
First, are you getting any errors in the Log while running the script?
Ensure your condition are being met by placing Print()s in them.
More info at - http://www.ninjatrader.com/support/f...ead.php?t=3418
-
Help programmazione
Hello,
I wrote a code for practice, below, says that to operate if the inclination is increasing dell'ADX:
Long if the slope of the SMA is 9> inclination of SMA 25 and MACD> its 10 EMA
Short if the slope of the SMA 9 is <than the SMA 25 and the MACD <10 of their EMA
Pressing the F5 key tells me OK, but when I focus on the graph, not doing anything long or short.
Why?
Thank you.
Ciao.
Roberto
#region Variables
private double livello1 = 0;
private double livello1B = 0;
private double livello2 = 0;
private double livello3 = 0;
private int ave = 0;
#endregion
protected override void Initialize()
{
Add(ADX(30));
Add(ADX(30));
Add(SMA(9));
Add(SMA(9));
Add(SMA(20));
Add(SMA(20));
Add(MACD(10, 25, 9));
Add(MACD(10, 25, 9));
CalculateOnBarClose = true;
}
#region CalcoliValori
private double Valore1()
{
return (ADX(30)[0]- ADX(30)[1])/ADX (30) [1];
}
private double Valore1B()
{
return (ADX(30)[1]- ADX(30)[2])/ADX (30) [2];
}
private double Valore2()
{
return (SMA(9)[0]-SMA(9)[1])/SMA(9)[1];
}
private double Valore3()
{
return (SMA(20)[0]-SMA(20)[1])/SMA(20)[1];
}
#endregion
#region OrderRouting
private void GestisciOrdini()
{
if (ADX(30)[0] != 0 && ADX(30)[1] != 0)
Valore1();
double livello1;
if (ADX(30)[1] != 0 && ADX(30)[2] != 0)
Valore1B();
double livello1B;
if (SMA(9)[1]!= 0 && SMA(9)[0] != 0)
{
Valore2();
double livello2;
}
if (SMA(20)[1] != SMA(20)[0])
{
Valore3();
double livello3;
}
}
#endregion
protected override void OnBarUpdate()
{
GestisciOrdini();
if( livello1 > livello1B && livello2 > livello3 && MACD(10, 25, 9).Avg[0] >SMA(MACD(10, 25, 9).Avg, 14)[0])
{
EnterLong(1, "ingresso Long ADX");
}
if ( livello1 > livello1B && livello2 < livello3 && MACD(10, 25, 9).Avg[0] < SMA(MACD(10, 25, 9).Avg, 14)[0])
{
EnterShort(1, "ingresso short ADX");
}
if (Position.MarketPosition == MarketPosition.Long && MACD(10, 25, 9).Avg[0] < SMA(MACD(10, 25, 9).Avg, 14)[0])
{
ExitLong("uscita long", "");
}
if (Position.MarketPosition == MarketPosition.Short && MACD(10, 25, 9).Avg[0] > SMA(MACD(10, 25, 9).Avg, 14)[0])
{
ExitShort("uscita short", "");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public double Livello1
{
get { return livello1; }
set { livello1 = Math.Max(100,value); }
}
[Description("")]
[GridCategory("Parameters")]
public double Livello1B
{
get { return livello1B; }
set { livello1B = Math.Max(100,value); }
}
[Description("")]
[GridCategory("Parameters")]
public double Livello2
{
get { return livello2; }
set { livello2 = Math.Max(100,value); }
}
[Description("")]
[GridCategory("Parameters")]
public double Livello3
{
get { return livello3; }
set { livello3 = Math.Max(100,value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Ave
{
get { return ave; }
set { ave = Math.Max(100,value); }
}
#endregion
}
}
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
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
238 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
4 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
||
Started by pechtri, 06-22-2023, 02:31 AM
|
10 responses
125 views
0 likes
|
Last Post Today, 12:03 AM |
Leave a comment: