![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2007
Location: , ,
Posts: 124
Thanks: 0
Thanked 0 times in 0 posts
|
Trying to learn NinjaScript language, I wanted to write down my first script in the line of Print("Hello world"); at the first shot I got syntax errors that scared me so I went doing : Tools/Edit NinjaScript/Strategy/SampleMACrossOver.
Then I clicked on the icon Compile and got the error message "Error on generating Strategy" and the following error report appeared below : ----- Description File Line Column Expected class, delegate, enum, interface, or struct Strategy\UserDefinedMethods.cs 22 20 Identifier expected Strategy\UserDefinedMethods.cs 25 16 Identifier expected Strategy\UserDefinedMethods.cs 25 28 Identifier expected Strategy\UserDefinedMethods.cs 29 16 Identifier expected Strategy\UserDefinedMethods.cs 29 37 Type or namespace definition, or end-of-file expected Strategy\UserDefinedMethods.cs 31 1 The namespace '<global namespace>' already contains a definition for '?' Strategy\UserDefinedMethods.cs 25 27 The namespace '<global namespace>' already contains a definition for '?' Strategy\UserDefinedMethods.cs 29 15 The namespace '<global namespace>' already contains a definition for '?' Strategy\UserDefinedMethods.cs 29 36 ----- Could any helpful NT user provide me with a NinjaScript that I just would have to type in and which, instead of "Hello world" would do {if (ADX(14)[0] > 30 Playsound(Connected.wav")} ? Gérard. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Gerard,
I would delete all files that you created. You can do this via Tools > Edit NinjaScript > Indicators, selecting a file you created and then press the "Delete" button. Do the same for strategies. Then open any system indicator and press F5 to compile? Hopefully it will compile. If not, double click on any error and fix the error, likely by deleting any code you created. Then for your code, implement your code as an indicator. Go through the wizard and once you get to the editor, just replace any code within OnBarUpdate() with the following code: Code:
if (ADX(14)[0] > 30)
PlaySound("Connected.wav");
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2007
Location: , ,
Posts: 124
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaTrader_Ray,
I took your advice and it worked, thanks a lot. I'd like to know : what data series or methods are available in order to get the most of the Time & Sales window ? I'd like to write a strategy dealing with it this way : if (TickPrice[0] = TickPrice[1] + TickSize) and (TickPrice[1] = TickPrice[2] + TickSize) then do begin PlaySound("Alert2.wav"); if (TickVolume[0) >= 100) or (TickVolume[1) >= 100) or (TickVolume[2) >= 100) then PlaySound("Announcement.wav"); end; Gerard |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You need to run the indicator with CalculateOnBarClose = false. This is tick by tick.
if (Close[0] == Close[1] + TickSize && Close[1] == Close[2] + TickSize) // Do something For volume, you have to self calculate the difference between the prior volume seen and the current volume. You have to store the last volume in a variable and then reset it to zero when the property FirstTickOfBar == true.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|