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

in 2 equal IF() did't run second action

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

    in 2 equal IF() did't run second action

    Good day.
    Give advice, please.
    I have code with 2 equal IF() and different action.
    Second action never runs.
    What can I do?

    Code:
    //8.30 - 13.30 LONG
    if (numberOfBars > 14 && 
    Position.MarketPosition == MarketPosition.Flat &&
    ToTime(Time[0]) >= 083000  && 
    ToTime(Time[0]) <= 133000) 			
    { 
        SetProfitTarget("", CalculationMode.Ticks, PT);
        SetStopLoss("", CalculationMode.Ticks, SL, false);
        EnterLongStop(N, V_line+3*TickSize, "");
    }	
    		
    //8.30 - 13.30 SHORT
    if (numberOfBars > 14 && 
    Position.MarketPosition == MarketPosition.Flat &&
    ToTime(Time[0]) >= 083000  && 
    ToTime(Time[0]) <= 133000)	
    { 
        SetProfitTarget("", CalculationMode.Ticks, PT);
        SetStopLoss("", CalculationMode.Ticks, SL, false);
        EnterShortStop(N, N_line-3*TickSize, "");
    }

    #2
    Same thing if to code like this:

    Code:
    if (numberOfBars > 14 && 
    Position.MarketPosition == MarketPosition.Flat &&
    ToTime(Time[0]) >= 083000  && 
    ToTime(Time[0]) <= 133000) 			
    { 
        SetProfitTarget("", CalculationMode.Ticks, PT);
        SetStopLoss("", CalculationMode.Ticks, SL, false);
        EnterLongStop(N, V_line+3*TickSize, "");
        EnterShortStop(N, N_line-3*TickSize, "");

    Comment


      #3
      Hello,
      Due to the Order Handling Rules for Managed Approached orders this is expected as you would not be able to submit an EnterLongStop() and EnterShortStop() at the same time.For more information on the Order Handling Rules for Managead orders please see the following link: http://ninjatrader.com/support/helpG...d_approach.htm To achieve what you are wanting to do you would need to use Unmanaged orders. For information on using Unmaganed Orders please see the following link: http://ninjatrader.com/support/helpG...d_approach.htm
      Cody B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      7 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      441 views
      0 likes
      Last Post Delerium  
      Working...
      X