![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
As you run the strategy --> Are there any error messages generated in the NinjaTrader Control Center log tab?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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)); } } |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
This likely will help - http://www.ninjatrader-support.com/v...ead.php?t=3170
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Quote:
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 |
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
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 |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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....
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
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 |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#11 | |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Quote:
FirstTickOfBar is described under: NinjaScript NinjaScript Language Reference Shared Data Methods and Properties Alternatively you can use the search function. Regards Ralph |
|
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
Ralph, excuse me if i annoy you... i tried the code not in backtesting but in simulation data feed, so in real time and gives me the signal, but is possible that read -1 as 0...so don't catch next open
|
|
|
|
|
|
#13 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Unfortunately negative "barsAgo" indexes are not support. You'll see an error in your logs.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Jul 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
Dierk the strategy gives me signals, also if i write O[-1], so if i can't use Open[-1] how can i say to ninja to entry in a specific level that includes the next open + (Sell limit) or - (Buy limit) something if i cant use -1?
Excuse me to all, thanks ... |
|
|
|
|
|
#15 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Unfortunately you can not use/access a price value in the future. This is not supported.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Josh or any advanced c# programmer please please help | whitegun | General Programming | 12 | 07-05-2008 11:33 AM |
| Josh, I lost workspace again... | funk101 | Miscellaneous Support | 1 | 04-06-2008 07:59 AM |