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

Simulated Stop Volume Trigger

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

    Simulated Stop Volume Trigger

    Hello, when using:

    Code:
    SetStopLoss(SIGNAL_NAME, CalculationMode.Ticks, StopLossTarget, [B]true[/B]);
    Simulated Stop is true.

    How can I change the Volume Trigger?

    Thanks

    #2
    Hello Rudmax,

    Thanks for opening the thread.

    This was answered previously in the thread here and the behavior has not changed. Volume Triggers are only used for ATM strategies.

    I have attached two screenshots showing NinjaTrader's historical processing using stop losses both simulated and non. As we can see on a 1 Volume chart, the fills are not affected by a volume trigger. This could be programmed into your strategy by checking the current volume, and then placing a buy or sell market order to exit when your desired price level is reached.

    Code:
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				...
    			}
    			else if (State == State.Configure)
    			{
    				SetStopLoss("", CalculationMode.Ticks, 1, true);
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			if(Position.MarketPosition == MarketPosition.Flat && Close[0] > Close[1])
    				EnterLong();
    			else
    			        SetStopLoss("", CalculationMode.Ticks, 1, true);
    		}
    Please let us know if you have any additional questions.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply but I'm trying this solution:

      Code:
      protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
              {
                  if (order.Name == "[B]Stop loss[/B]" &&
                      order.CustomOrder != null &&
                      order.CustomOrder.[B]IsSimulatedStopEnabled[/B] &&
                      orderState == [B]OrderState.TriggerPending[/B])
                  {
                      order.CustomOrder.[B]VolumeTrigger[/B] = [I][B]SimulatedOrderVolumeTrigger[/B][/I];
                      order.CustomOrder.Update();
                  }
              }
      after a test, it is working like a charm!

      Best Regards,
      Last edited by Rudmax; 05-24-2018, 02:34 PM.

      Comment


        #4
        Hello Rudmax,

        I know that CustomOrder is used for some under-the-hood ATM strategy handling. This is kept undocumented/unsupported, but I'm glad you have found and shared your use of this code for others! Keep in mind though, there maybe some code breaking changes with new releases of NinjaTrader since CustomOrder is not sealed and documented for public use.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        20 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X