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 in private IOrder stopOrder . can't implicitly convert the void type

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

    error in private IOrder stopOrder . can't implicitly convert the void type

    Oh, hello. Thank you for your time. Excuse my English.
    I have this code that works correctly

    SetStopLoss("MyLongEntry" + CurrentBar, CalculationMode.Price,(Low[0]- 2*TickSize), false);

    But if I make this modification.

    private IOrder stopOrder = null;

    if (entryOrder != null && entryOrder == execution.Order)
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    {

    stopOrder = SetStopLoss("MyLongEntry" + CurrentBar, CalculationMode.Price,(Low[0]- 2*TickSize), false);

    }
    }

    gives this error: you can not implicitly convert the void type.
    Would you be so kind as to point me in the right direction? Thank you.




    #2
    Hello julifro,

    Thanks for your post.

    SetStopLoss is a method of type void and does not return an IOrder object. If you would like to have an IOrder object returned, I suggest using one of the Exit methods of the Managed Approach and to follow the SampleOnOrderUpdate strategy for using Exit methods to control your profit target and stop loss instead of using the Set methods.

    Publicly available resources are linked below.

    Managed Approach - https://ninjatrader.com/support/help...d_approach.htm

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for your quick response.
      Before asking the question I was reading the help on
      SetStopLoss and I didn't read that it was a void method.

      I have written some indicators with easy code but the progression in ninjatrader strategies is very frustrating for me. There is always something that escapes me.

      Do you know of any book or orderly method to master ninjatrader programming? thank you.

      Comment


        #4
        Hello julifro,

        NinjaTrader does not offer any books on NinjaScript. We keep all supported NinjaScript documented in the Help Guide and include some educational resources there as well.

        Educational Resources - https://ninjatrader.com/support/help..._resources.htm

        Language Reference - https://ninjatrader.com/support/help...erence_wip.htm

        If you have any additional ideas on materials that we could include, I'll be happy to track your feedback in a feature request.

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        2 views
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        6 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        217 views
        1 like
        Last Post PaulMohn  
        Working...
        X