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 chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Working...
        X