Announcement

Collapse
No announcement yet.

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

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        88 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        135 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        69 views
        0 likes
        Last Post PaulMohn  
        Working...
        X