Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need some Help with my Strategy

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

    Need some Help with my Strategy

    I am trying to sequentially and automatically move my StopLoss to breakeven when my profit reaches 2X dollars( this is for each position), from then on, I want to increase it X dollars every time my profit goes up X dollars. I don't want a TrailingStop. Do you have a sample code that may help me do precisely this?

    #2
    Hello Yandychang,

    Thank you for your post.

    We do have a sample similar to this idea but not exact. You can view this sample at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3222

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello Patrick
      I tried the following variation: I has no syntax error but although it makes sense on my mind, it does not do what I expect it to do:
      #region *********** Money Management***********************
      n = Math.Truncate( Math.Abs((Close[
      0]-Position.AvgPrice))/lossStop);
      if (Position.MarketPosition == MarketPosition.Flat)
      {
      SetStopLoss(CalculationMode.Price,Position.AvgPric e-lossStop);
      }

      if (Position.MarketPosition == MarketPosition.Long)
      {
      if (n>=1)
      {
      // Once the price is greater than entry price+n*lossStop , Increase StopLoss to Position.Avg+(n-1)lossStop;
      if (Close[0] > Position.AvgPrice + n*lossStop)
      {
      SetStopLoss(CalculationMode.Price,Position.AvgPric e+(n-
      1)*lossStop);
      }
      }
      else
      SetStopLoss(CalculationMode.Price,Position.AvgPric e-lossStop);
      }
      #endregion

      one thing I have a hard time wrapping my head around is when I use SetStopLoss(x) I understood x meant the amount currency the price must drop before if sells. The example you directed me, seems to actually tell NT the price to sell it for(SetStopLoss(PositionAvg+x)) which one is right?

      Comment


        #4
        Hello Yandychang,

        Thank you for your response.

        When using the CalculationMode you can use a double value for the level of the Stop. Otherwise by default it uses currency within the parentheses. Please visit the following link for more information on the syntaxes that can be used: http://www.ninjatrader.com/support/h...etstoploss.htm

        What are you attempting that is not occurring? Do you have a full or test script that I may test?

        Comment


          #5
          Hello Patrick

          Now I know what i was doing wrong, I needed to convert my stoploss in currency to amount of ticks... Using Pointvalue and ticksize, I did this and seemed to have worked.

          I do have another question, i have various different signal names. If i set up conditional stoplosses with those signal names, would the system use the signals corresponding money management when the signal is triggered?

          Comment


            #6
            Hello YandyChang,

            Thank you for your response.

            You would need to use the following syntax to include the fromEntrySignal in the SetStopLoss():
            • SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool simulated)

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            27 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 04-23-2024, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            193 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,235 views
            0 likes
            Last Post xiinteractive  
            Working...
            X