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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X