Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Verify and List Stop

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

    Verify and List Stop



    I do not want to call this per tick or per price changer and I need a new order for OnOrderUpdate

    This list close to what I want to do but I have had times where the stop was not low enough and does not exist. I do want to check perhaps on a timer sine I


    I am thinking I could run if (IsFirstTickOfBar )
    OnOrderUpdate(null,null.....)


    Click image for larger version  Name:	MoveStoptoBE.PNG Views:	0 Size:	28.6 KB ID:	1199411I want to ensure I have a stop order in place. Sometimes a stop is not placed
    I would like to also list what my current position risk is

    Print ("Risk ="+ (Position.AveragePrice - stopOrder.StopPrice) ); in this case I have a risk of 1.5 points in MNQ this is s 2:1 reward to risk I would like to have a second strategy monitoring my order entry strategy.
    Last edited by BartMan; 04-30-2022, 05:08 PM.

    #2
    Hello BartMan,

    The SampleMonitorStopProfit is setting stops and targets with SetStopLoss() and SetProfitTarget() in State.Configure.

    These orders are set before the entry is placed and are automatically submitted once the entry order fills.

    Is this what you are doing?

    Are you trying to use exit orders and submit these in OnOrderUpdate()?
    See the ProfitChaseStopTrailExitOrdersExample_NT8 linked below.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am not using the chase stop samples. I want to convert from a fixed number or percentage, I want to generate a Risk (R) based approach

      I need to get the stop price in order to determine my initial risk. I will use a combination of SampleMonitorStopProfit code and capture from OnExecutionUpdate.

      However I also want to handle the disconnect and reconnect events. I want to say onconnect event:
      Do I have a position?
      Do I have a stop in place?



      Code:
      PNL = Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency, Close[0]);
      
      Print ("string PNL=" + PNL.ToString() + " pnldirect + PNL"); ///TODO: Calculate Risk
      
      if (PNL > 1000) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 900 ) );
      if (PNL > 900) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 800 ) );
      if (PNL > 700) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 500 ) );
      if (PNL > 500) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 450 ) );
      if (PNL > 300) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 200 ) );
      if (PNL > 200) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 150 ) );
      if (PNL > 150) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 110 ) );
      if (PNL > 120) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 100 ) );
      ///Better than BE
      if (PNL > 20) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Direction * 5 ) );
      
      ///SetStopLossSafe(CalculationMode.Price, Position.AveragePrice + ( Direction * 5 ));
      ///This function will wrap SetStopLoss in try catch block for trapping errors
      
      ///Once Risk is calculated.
      /*
      // Long Example
      Risk = Position.AveragePrice - Stop;
      if (PNL > Position.AveragePrice + Risk * 1) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( 0 ) );
      if (PNL > Position.AveragePrice + Risk * 2) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Risk * 1 ) );
      if (PNL > Position.AveragePrice + Risk * 3) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Risk * 2 ) );
      if (PNL > Position.AveragePrice + Risk * 4) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Risj * 3 ) );
      if (PNL > Position.AveragePrice + Risk * 5) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Risk * 4 ) );
      if (PNL > Position.AveragePrice + Risk * 6) SetStopLoss( CalculationMode.Price, Position.AveragePrice + ( Risk * 5 ) );
      
      
      
      */


      Comment


        #4
        Hello BartMan,

        What is the issue you having you would like assistance with?

        The if statements you have are all going to evaluate as true. if PNL is greater than 1000 then its greater than 20 as well and all conditions below are going to evaluate as true.

        Are you printing Position.AveragePrice + ( Direction * 5 ) when the Position.MarketPosition is MarketPosition.Long and finding the TraceOrders is showing the stop loss is not being set to the price supplied?

        Below is a link on using Print() and TraceOrders to understand behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          TraceOrders = true; should suffice. It somehow was set to false inside (State == State.SetDefaults).

          Previously I thought I had set it to true. I beleive I created a new template and had not reset it.

          Thank You this can be marked closed/resolved.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          58 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 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