• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cannot access instrument name from superdom columns

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

    cannot access instrument name from superdom columns

    I cannot access the instrument name from superdom columns. this works in strategies and not here. how do I fix it.
    it fails on this line
    Print(DateTime.Now + Instrument.FullName + "Crossed below ask");


    Severity Code Description Project File Line Suppression State
    Error CS0120 An object reference is required for the non-static field, method, or property 'Instrument.FullName' NinjaTrader.Custom C:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\SuperDomColumns\Pipsfromentry.cs 46 Active


    Code:
    //This namespace holds SuperDOM Columns in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.SuperDomColumns
    {
    	public class Pipsfromentry : SuperDomColumn
    	{
    		private double limitprice;
    		private double stopprice;
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom SuperDOM column here.";
    				Name								= "Pipsfromentry";
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    
    		protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    		{
                if (limitprice > 0 && marketDataUpdate.Ask < limitprice)
                {
                    Print(DateTime.Now + Instrument.FullName + "Crossed below ask");
                }
    			
    		}
    
    		protected override void OnOrderUpdate(OrderEventArgs orderUpdate)
    		{
    			if(orderUpdate.Filled==orderUpdate.Order.Quantity)
    			{
    				stopprice=0;
                    limitprice = 0;
                    return;
                }
    			
    				
                if (orderUpdate.Order.OrderType == OrderType.MIT )
                { 
                    limitprice = orderUpdate.LimitPrice;
    
                }
    			
    			
    		}
    
    		protected override void OnRender(DrawingContext dc, double renderWidth)
    		{
    			// test
    		}
    
    	}
    }

    #2
    Hello,

    Thank you for the question.

    This error would be expected as you are accessing a Static class named Instrument rather than the Inherited property which Indicators and Strategies have.

    When you are programming outside of an indicator or strategy, you will find items like this where a property may be valid in a Indicator or strategy but is no longer valid in this type.

    Looking at the other columns that are included with the platform you will be able to find most of the syntax needed that applies directly to a SuperDomColumn.

    In the script in general, you could use:
    Code:
    Print(DateTime.Now + SuperDom.Instrument.FullName + "Crossed below ask");
    To find the instrument for the OnMarketData event, you could also use:
    Code:
    Print(DateTime.Now + marketDataUpdate.Instrument.FullName + "Crossed below ask");

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      cool, that works but I got another issue
      I enter order using MIT and when I look at the order update, the limit price is zero.
      how can I get the MIT price of the order just entered using orderupdate?
      protected override void OnOrderUpdate(OrderEventArgs orderUpdate)
      {
      if(orderUpdate.Filled==orderUpdate.Order.Quantity)
      {
      stopprice=0;
      limitprice = 0;
      return;
      }


      if (orderUpdate.Order.OrderType == OrderType.MIT )
      {
      limitprice = orderUpdate.LimitPrice;
      Print(DateTime.Now + SuperDom.Instrument.FullName + OrderType.MIT + orderUpdate.LimitPrice);

      }


      }

      Comment


        #4
        ignore the question as I found the answer-orderUpdate.StopPrice
        if (orderUpdate.Order.OrderType == OrderType.MIT )
        {
        limitprice = orderUpdate.StopPrice;
        Print(DateTime.Now + SuperDom.Instrument.FullName + OrderType.MIT + orderUpdate.StopPrice);

        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by alwathein, Today, 02:15 AM
        0 responses
        2 views
        0 likes
        Last Post alwathein  
        Started by norstrigh, Yesterday, 11:58 PM
        0 responses
        4 views
        0 likes
        Last Post norstrigh  
        Started by swcooke, Yesterday, 08:34 PM
        0 responses
        4 views
        0 likes
        Last Post swcooke
        by swcooke
         
        Started by tvaughan4, Yesterday, 04:37 PM
        0 responses
        3 views
        0 likes
        Last Post tvaughan4  
        Started by Convert, Yesterday, 03:44 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X