Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninjascript basic

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

    Ninjascript basic

    Can Ninjatrader suggest a good place to start learning ninjascript? What does "e." mean as in
    if (e.MarketDataType == MarketDataType.Last)
    Print("Last = " + e.Price + " " + e.Volume);
    ?
    I know it may be a very simple question but it is really difficult to search for the meaning of "e." for one who doesn't know the right place. Thank a lot if anyone could help.

    #2
    Hello,

    Thanks for your note.

    Actually e.MarketData is getting into some more advanced NinjaScript and programming.

    Please check out the following page for infomration on this:



    You can see for the method OnMarketData(MarketDataEventArgs e) we assign the input data the variable of e here. Then we use e in our OnMarketUpdate to reference the inputted data. If you changed the letter here in the parameter constructor you would need to use a different letter.

    For example:

    OnMarketData(MarketDataEventArgs d)


    Now I would need to use d.MarketData if I choose not to use the standard e for whatever reason.


    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks a lot for your answer. It is very helpful indeed.

      As in the guide

      protected override void OnMarketData(MarketDataEventArgs e)
      {
      // Print some data to the Output window
      if (e.MarketDataType == MarketDataType.Last)
      Print("Last = " + e.Price + " " + e.Volume);
      else if (e.MarketDataType == MarketDataType.Ask)
      Print("Ask = " + e.Price + " " + e.Volume);
      else if (e.MarketDataType == MarketDataType.Bid)
      Print("Bid = " + e.Price + " " + e.Volume);

      I'm a bit confused by the meaning of the above. Does it means that the varibale e can either be last/ask/bid (or to say there are three marketdatatype?) , depending on the incoming data? So the data we received from OnMarketData update is something like
      Bid-Price-Volume
      Bid-Price-Volume
      Ask-Price-Volume
      etc..
      Somewhat like what we saw in time and sales windows?

      Do you think there are some simple indicators that one may start studying ninjascript from them? I am curious about how one can write an indicator comparing the performance of two reference assets, for example a particular stock and ES mini intraday. Is it possible in Ninja?

      Comment


        #4
        Hello,

        Yes this is possible, e is actually not just a variable as it hold many arguments. Such as Ask, Bid, last, Volume, Time to name a few. What you mention should be possible if I understand you correctly.

        An example of using OnMarketData() in use would be here:



        More samples here:

        Following are links to all available NinjaScript reference samples within this forum section: Strategy Reference Samples (NinjaTrader 8) - also applicable to NT7 Using a time filter to limit trading hours (http://www.ninjatrader.com/support/forum/showthread.php?t=3226) Using multiple entry/exit signals simultaneously


        Let me know if I can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 05:56 AM
        1 response
        3 views
        0 likes
        Last Post Jltarrau  
        Started by Jltarrau, Today, 05:57 AM
        0 responses
        4 views
        0 likes
        Last Post Jltarrau  
        Started by Stanfillirenfro, Yesterday, 09:19 AM
        7 responses
        51 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TraderCro, 04-12-2024, 11:36 AM
        4 responses
        70 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Mindset, Yesterday, 02:04 AM
        1 response
        15 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X