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

Stop Loss

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

    Stop Loss

    hello,
    I'm set Stop Loss in percentage to OnBar Update (), if the position is flat. For example:

    protected override void OnBarUpdate ()
    {
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss ("", CalculationMode.Price (Close [0] - (Close [0] * (1 +2))), false) ; // Stop 2%
    }

    is correct to do as above ?

    Or should I do this:

    SetStopLoss("", CalculationMode.Percent, 2, false);// Stop 2%

    or how?
    Ciao.
    Roberto

    #2
    Hello Roberto,

    You'll want to use the decimal equivalent for the value you're looking for.

    A 2% stop loss can be expressed:

    SetStopLoss("", CalculationMode.Percent, .02, false);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks RyanM,
      I have another question.
      If I'm set the Stop Loss of 2,5 % below the purchase price, using the command Price, that's okay:
      SetStopLoss(" ", CalculationMode.Price,(Position.AvgPrice *(1 - .025)) , false);

      As for the stop of 2.5% above the purchase price, that's okay:
      SetStopLoss(" ", CalculationMode.Price,(Position.AvgPrice *(1 + .025)) , false);
      Ciao.
      Roberto

      Comment


        #4
        Yes Roberto, that math looks correct.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          What is the difference between the set StopLoss:
          SetStopLoss ("", CalculationMode.Percent, .02, false);
          or so "", CalculationMode.Percent, .02,);Ascolta
          Trascrizione fonetica
          Ciao.
          Roberto

          Comment


            #6
            in the previous mail there are errors of transcription

            What is the difference between the set StopLoss:
            SetStopLoss ("", CalculationMode.Percent, .02, false);
            or so: CalculationMode.Percent, .02,);
            the use of false what does this mean?
            Ciao.
            Roberto

            Comment


              #7
              Roberto, the stop will be either simulated or not - means if it's simulated it will not be submitted until triggered, so you can effectively hide your stops.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Hello, please, ask for help because I'm stuck in this part of code.
                I created a # region OrderRouting to manage operations Long / Short,with two Breakeaven (Be1 and Be2).Working with Stoks use the percentage calculation to set the Stop.
                When you experience the conditions of 1st Breakeaven (BE1) and the AvgPrice+3%, the stop price move to AvgPrice. Second contidion,Breakeaven 2° (BE2) and the AvgPrice+5% the stop move to AvgPrice+ 3%.
                okay if I do this:

                #region OrderRouting
                private void ManagerOrder ()
                {
                if (Position.MarketPosition == MarketPosition.Long)
                {
                if( Be1 && High[0] > Position.AvgPrice * (1+0.03))
                SetStopLoss(" ", CalculationMode.Price,Position.AvgPrice, false);


                if( Be2 && High [0] > Position.AvgPrice *(1+0.05))
                SetStopLoss("LongFibonacci°", CalculationMode.Price,Position.AvgPrice*(1+0.03), false);

                or so:
                if( Be1 && High[0] > Position.AvgPrice + (Position.AvgPrice* (1+0.03)) )
                SetStopLoss(" ", CalculationMode.Price,Position.AvgPrice, false);

                Thanks for the valuable help they always give us.
                Ciao
                Roberto

                Comment


                  #9
                  Italy, can you please clarify? I'm not sure what the question is.
                  AustinNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by gentlebenthebear, Today, 01:30 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by Aviram Y, Today, 05:29 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by cls71, Today, 04:45 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by TradeForge, Today, 02:09 AM
                  1 response
                  22 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by elirion, Today, 01:36 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post elirion
                  by elirion
                   
                  Working...
                  X