Josh please can you help me?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Josh please, help me
Collapse
X
-
Josh please, help me
Hi guys, I'm an italian student adm i'm improving my thesys about trading system. I developed my code in easylanguage and now i'm trying to , translate it in C# for ninjia . I compile the code but when apply it on chart ninjia doesn't provide the signals.I think there are mistakes about ninja script...It's symple long/short limt order es long next open +(stddev(High-low)*Mul) if Ema fast > Ema slow .
Josh please can you help me?Tags: None
-
Thannks Ray for the reply, i wrote the code and compile it, without problem, but when i apply it in simulation Ninjia doesn't provide the signal...This is the central of my code if you could help me...to solve the problem
private int mlt = 2; // Default setting for Mlt
private int lenta = 50; // Default setting for Lenta
private int veloce = 10; // Default setting for Veloce
private int giorni = 5; // Default setting for Giorni
double Value1;
double Value2;
private DataSeries HighMenoOpen;
private DataSeries OpenMenoLow;
// User defined variables (add any user defined variables below)
#endregion
///
<summary>
///
This method is used to configure the strategy and is called once before any strategy method is called.
///
</summary>
protected overridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Price, Mlt*StdDev(High, 5)[0]);
CalculateOnBarClose = true;
}
///
<summary>
///
Called on each bar update event (incoming tick)
///
</summary>
protected overridevoid OnBarUpdate()
{
HighMenoOpen.Set(High[1] - Open[1]);
OpenMenoLow.Set(Open[1] - Low[1]);
Value1 = StdDev(HighMenoOpen , giorni)[1];
Value2 = StdDev(OpenMenoLow , giorni)[1];
// Condition set 1
if (EMA(Veloce)[1] > EMA(Lenta)[1] && Position.MarketPosition!=MarketPosition.Long);
{
EnterLongLimit(1,Open[0] - (Value2 * Mlt));}
if(Position.MarketPosition==MarketPosition.Long)
{
ExitLongLimit(Open[0] + (Value1 * Mlt));
}
// Condition set 2
if
(EMA(Veloce)[1] < EMA(Lenta)[1] && Position.MarketPosition!=MarketPosition.Short);
{
EnterShortLimit(1,Open[0] + (Value1 * Mlt));}
if
(Position.MarketPosition==MarketPosition.Short)
{
ExitShortLimit(Open[0] - (Value2 * Mlt));
}
}
Comment
-
This likely will help - http://www.ninjatrader-support.com/v...ead.php?t=3170RayNinjaTrader Customer Service
Comment
-
Hi giucol,Originally posted by giucol View PostThis method is used to configure the strategy and is called once before any strategy method is called.
///
</summary>
protected overridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Price, Mlt*StdDev(High, 5)[0]);
CalculateOnBarClose = true;
}
you use an indicator's return value from StdDev() in SetProfitTarget() in Initialize(). Initialize() is called before your strategy starts. So, what do you expect StdDev() to return during initialization? I guess it wouldn't return a useful result anyway?
Regards
Ralph
Comment
-
Ralph you have reason, i have to delete Set profit target..., but i think the problem is in the code about Value1 and Value2 because i neeed to catch the standard deviation of high meno Open for value1 and standard deviation of Open meno low for value2, I used data series
HighMenoOpen and OpenMenoLow, the compile is ok, but i dont know if that's ok.
I also make an indicator to plot Value1 and Value2, the compile is ok but Ninjia doesn't plot nothing...
Please help me , safe me...
Comment
-
Hi giucol,
you declare two DataSeries variables (HighMenoOpen, OpenMenoLow) and you use it in OnBarUpdate() as class instances without instantiation. Don't think this works. For an class instantiation example look at the "Reference Samples" section. There is a packet "Synchronizing a DataSeries object to a secondary time frame". It explains how and where to generate a DataSeries class instance.
Regards
Ralph
Comment
-
To Indicate Next Bar
THANKS RALPH I SOLVE THE PROBLEM TO PLOT VALUE 1 AND A VaLUE 2...NOW I NEED TO IMPLEMENT MY STRATEGY, I NEED TO INSERT AN ORDER LIMIT..IN EASY LANGUAGE CODE Buy ("LongScalp") next bar at open of next bar -
(Value2*Mlt) limit;
I wrote in C# this code for next Open
if (EMA(Veloce)[0] > EMA(Lenta)[0] && Position.MarketPosition!=MarketPosition.Long);
{
EnterLongLimit(1,Open[-1] - (Value2 * Mlt));}
if(Position.MarketPosition==MarketPosition.Long)
{
ExitLongLimit(Open[-1] + (Value1 * Mlt));
I don't if i can use to indicate next bar -1
Please help me, andyou don't hate me....
Comment
-
Never fear, no reason to hate you.
You can't access a bar in the future (would be a nice feature to return the prices of a future bar). But you can find out if a new bar has started by property "FirstTickOfBar". In the help-section of NT there is a little example how to use it.
Regards
Ralph
Comment
-
Thanks Ralph, i tried to aplly the code with
if (EMA(Veloce)[0] > EMA(Lenta)[0] && Position.MarketPosition!=MarketPosition.Long);
{
EnterLongLimit(1,Open[-1] - (Value2 * Mlt));}
if(Position.MarketPosition==MarketPosition.Long)
{
ExitLongLimit(Open[-1] + (Value1 * Mlt));
}
and now ninja gives me the signal....but do you tink that open[-1] is a mistake?
Pease can you tell me the section about "FirstTickOfBar"...Thanks Ralph
Comment
-
I think first element of an open[]-array has the index number 0. If -1 works too, then you could check whether it contains the correct number. I wouldn't expect that. But, when you ever run this strategy in real time (and not only for backtesting) a reference into the future can never work.Originally posted by giucol View Post...and now ninja gives me the signal....but do you tink that open[-1] is a mistake?
Pease can you tell me the section about "FirstTickOfBar"...
FirstTickOfBar is described under:
NinjaScript
NinjaScript Language Reference
Shared Data Methods and Properties
Alternatively you can use the search function.
Regards
Ralph
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
582 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment