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!
See more
See less

Partner 728x90

Collapse

Hello world

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hello world

    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
    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");
    RayNinjaTrader Customer Service

    Comment


      #3
      Some further programing

      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

      Comment


        #4
        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.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        9 views
        0 likes
        Last Post cre8able  
        Working...
        X