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

trailing stop issue

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

    trailing stop issue

    I am trying to make a trailing stop but having issues this is what I have so far the issue the trailing stop will not activate


    what i am trying to do is have a stop then after a certian amount of ticks it will convert to a trailing stop.

    the third condition is if the user double clicks it will cancell the trailing stop and set a hard stop so the user can move it freely.




    ///condition flat

    if(bRedBar == true && nCount == 0)
    {
    if(Close[0] > Open[0] + 5*TickSize)
    {
    EnterShortStopMarket(nNumberOfSetContracts, nEntryPrice, "Short1");
    SetStopLoss("Short1", CalculationMode.Ticks, 11, false);
    SetProfitTarget("Short1", CalculationMode.Ticks, 10);

    EnterShortStopMarket(nNumberOfContractsRunner,nEnt ryPrice,"Short2");
    SetStopLoss("Short2", CalculationMode.Ticks, 11, false);


    nCount = 0;
    }




    if(Position.MarketPosition == MarketPosition.Long && Position.Quantity == 1)

    {
    if(bRedBar == true && nCount ==0)
    {
    if(Close[0] > Open[0] + 5*TickSize)
    {
    EnterShortStopMarket(nNumberOfSetContracts, nEntryPrice, "Short1");
    SetStopLoss("Short1", CalculationMode.Ticks, 11, false);
    SetProfitTarget("Short1", CalculationMode.Ticks, 10);
    if(bTrailStopSet == false)
    {
    SetTrailStop("Short2", CalculationMode.Ticks, 18, false);
    bTrailStopSet = true;

    }

    nCount ++;
    }

    if(bManualStopMovement == true && bManualStopOverride == false )
    {
    SetStopLoss("Short2", CalculationMode.Ticks, 18, false);
    bManualStopOverride = true;
    }

    }



    }

    #2
    Hello ballboy11,

    What is the condition that is not triggering?

    Have you used prints to find why the condition is not triggering?

    Please include the output from your prints if you would like assistance debugging the logic.

    Below is a link to examples I've posted that demonstrate trailing and chasing logic.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I read the manual and I guess SetStopLoss(name1) && SetTrailingStop(name1) can not be used at the same time. So the question is after so many ticks can I remove SetStop loss and add setTrailingStop? Set Stop loss will always override the trailstop

      Comment


        #4
        Hello ballboy11,

        No, Set methods cannot be unset. If SetStopLoss is used SetTrailStop will not work.

        You can instead move the stop loss using logic as I have demonstrated in the ProfitChaseStopTrailSetMethodsExample_NT8 example I have linked in my previous post.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes, I understand what I did was use a trailing stop and update it until my max trailing stop was reached.

          If initial stop was 11 ticks and after so many ticks I changed my trail stop to 15

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          19 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
          20 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