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

error CS0029.

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

    error CS0029.

    Hello

    In the interface of the strategy I want to put the option to select the type of order with which I want to work, after looking in the forum and in the ninjatrader documentation, I have reached a point where I do not know how to continue, I get an error CS0029.

    I attach an image,
    After logic for entries, it runs in OnBarUpdate
    PHP Code:
    if (shortEntry == null && EntryReverseOrders == false && EntryStopLimitOrders == false && EntryStopOrders == false && EntryLimitOrders  ==true)
    SubmitOrderUnmanaged(0OrderAction.SellShortOrderType.Limit1,Close[0], 0oco"Short limit entry"); 
    At this moment the way I have to choose the order with which I want to work from the interface is through the use of four options marked as true or false, just an option of 4

    I appreciate any help.
    Thank you very much
    Attached Files

    #2
    Hello franki,

    Thank you for the post.

    Because NinjaScript is C#, the errors you see you can search for online to get more specific details surrounding its meaning.

    In this case, the error you mentioned specifically means: Cannot implicitly convert type 'int' to 'string'. I cannot see where this is coming from in what you provided, an image of the code would not necessarily be as helpful as the actual code as I cannot test what you provided.

    Regarding what you described, I would suggest taking a different approach at this. I see you defined your own enum of types of orders, but this already exists in NinjaTrader so there is no need to recreate this enum.

    You could make a property like the following if you wanted an order type selector:


    Code:
    protected override void OnStateChange()
    {
    	if (State == State.SetDefaults)
    	{
    		MyOrderType = OrderType.MIT;
    	}
    }
    
    protected override void OnBarUpdate()
    {
    	if(MyOrderType == OrderType.Market)
    	{
    		
    	}
    }
    
    [NinjaScriptProperty]
    [Display(Name = "My Order Type ", GroupName = "NinjaScriptParameters", Order = 1)]
    public OrderType MyOrderType
    { get; set; }
    The existing enums in NinjaScript like OrderType can be reused so you don't have to reinvent the wheel so to speak.

    If you create a property like this, you can also use this everywhere in your class which will likely remove the need for the 4 bool variables you have. Where you are using the bool variables now, you can instead check the value of MyOrderType.

    You could even go as far as passing this value directly to your SubmitOrderUnmanaged method:

    Code:
    SubmitOrderUnmanaged(0, OrderAction.SellShort, [B]MyOrderType[/B], 1,Close[0], 0, oco, "Short limit entry");
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Jesse thank you very much
      I used the first example, but in the drop-down menu of the script interface there are types of commands not used or encoded in OnBarUpdate, it is not very important but is there any way to eliminate it?

      The second example... I tried to use it before publishing the first message, but it is not compatible (I think) using Close [0] (or other combinations of variables) as a stop price or as a limit price, being in the same position in the SubmitOrderUnmanaged command.

      I thank you for your contribution and I apologize for my limitations in C #

      Comment


        #4
        Hello franki,

        Thank you for the reply.

        There is no way to edit the values inside of the existing enum. You would have to create your own enum type that contains the OrderTypes that you need.

        On your second question, the line

        Code:
        SubmitOrderUnmanaged(0, OrderAction.SellShort, MyOrderType, 1,Close[0], 0, oco, "Short limit entry");
        compiles correctly on my end. Could you please post the error that you are getting along with your code?

        I look forward to your reply.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hello franki,

          Thank you for the reply.

          There is no way to edit the values inside of the existing enum. You would have to create your own enum type that contains the OrderTypes that you need.
          Hello NinjaTrader_ChrisL!
          the error CS0029. It happens in the attached image in the first of my messages.

          Finally I have chosen to filter the types of unwanted orders in the first solution exposed by NinjaTrader_Jesse, to give a null value to the unwanted orders through a Boolean option.
          Originally posted by NinjaTrader_ChrisL View Post
          On your second question, the line

          Code:
          SubmitOrderUnmanaged(0, OrderAction.SellShort, MyOrderType, 1,Close[0], 0, oco, "Short limit entry");
          compiles correctly on my end. Could you please post the error that you are getting along with your code?

          I look forward to your reply.
          In the second question, in the call line for the unmanaged order, no coding error occurs, the error occurs when the strategy is running and applies stopmarket price values in the stoplimit type orders and vice versa.
          An error message is displayed indicating that the stop price can not be higher than the limit price.
          This happens because the price variables do not have the same conditions for stoplimit prices and stopmarket prices

          Example..
          Code:
          shortEntry = SubmitOrderUnmanaged(1, OrderAction.SellShort, OrderType.StopLimit, 1, [B]Close[0] * TickSize(Limit Price)[/B], [B][U]Low[0]  * TickSize(Stop Price)[/U][/B] , oco, "Short limit entry");
          if I change nothing more the order type
          Code:
          shortEntry = SubmitOrderUnmanaged(1, OrderAction.SellShort, OrderType.StopMarket, 1, [B]Close[0] * TickSize(Limit Price)[/B], [B][U]Low[0]  * TickSize(Stop Price)[/U][/B] , oco, "Short limit entry");
          apply the value "Close[0]" when the correct value is zero
          the correct way that does not give error is the following:
          Code:
          shortEntry = SubmitOrderUnmanaged(1, OrderAction.SellShort, OrderType.StopMarket, 1, [B]0(Limit Price)[/B], [B][U]Close[0]  * TickSize(Stop Price)[/U][/B] , oco, "Short limit entry");
          It's because of this that using MyOrderType inside SubmitOrderUnmanaged gives problems in the execution of the script.

          If there is an alternative solution, it is beyond the scope of my understanding both about ninjatrader and C #

          I greatly appreciate the support

          Thank you very much

          Comment


            #6
            Hello franki,

            Thanks for the reply.

            If you are submitting a sell stop market or sell stop limit, the prices that you select for those limits must be below the market price. Please first check to make sure that your stop and limit prices are below market price before attempting to submit the order.

            Please let me know if you have any questions.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thank you very much for your attention NinjaTrader_ChrisL
              Finally to solve the crossing prices of stop, stoplimit, etc ... I have created several SubmitOrderUnmanaged sequences and in each of them I added a variable according to order type to delimit the price, so by selecting the order type in MyOrderType select the command of SubmitOrderUnmanaged with the correct variables of each price.
              I do not know if it's the most orthodox, but it works correctly and I have no problems with the price even when I change the order type.
              For now I have no more questions
              Thank you very much

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by inanazsocial, Today, 01:15 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by rocketman7, Today, 02:12 AM
              0 responses
              10 views
              0 likes
              Last Post rocketman7  
              Started by dustydbayer, Today, 01:59 AM
              0 responses
              1 view
              0 likes
              Last Post dustydbayer  
              Started by trilliantrader, 04-18-2024, 08:16 AM
              5 responses
              23 views
              0 likes
              Last Post trilliantrader  
              Started by Davidtowleii, Today, 12:15 AM
              0 responses
              3 views
              0 likes
              Last Post Davidtowleii  
              Working...
              X