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

Setting stop and profit targets at entry bar

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

    Setting stop and profit targets at entry bar

    Hello,
    I am wanting to use MIN of the last 5 bars as a stop loss upon entry into a position. However, as new bars form, MIN changes. Is there a way I can dictate the strategy to set the stop loss based on the MIN(5) of the entry bar? I want the Stop to stay static. Similar to the way an ATM strategy would work while being dynamic to the situation.

    I am currently assigning a stopmode = 0 (user variable) upon entry and dictating that "if stopmode = 0, then set a stop market order at the MIN(5)(Low)"

    Thanks,

    Dave

    #2
    Hello DavidParkins,

    Yes that is possible, you would use a double variable for that to store the MIN at the time of the entry to the variable. Later when submitting a stop you could use the variable price which represents the MIN of the last entry time.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello DavidParkins,

      Yes that is possible, you would use a double variable for that to store the MIN at the time of the entry to the variable. Later when submitting a stop you could use the variable price which represents the MIN of the last entry time.

      I look forward to being of further assistance.
      I feel silly, but Im lost here. Im not sure how to save the time of my entry with the MIN.

      Ill explain what I have so far.
      Set1 = If 'Entry Conditions' are met, do the following >>> EnterLong, StopMode(User Variable (Int)) = 0

      Set2 = If Position.Market Position = MarketPosition.Long and StopMode = 0, do the following >>> ExitLongStopMarket(DefaultQuantity, MIN(Low,5)[0],"","");

      Set3 = Similar to step 2 but will be a take profit.

      I Tried MIN(low,5)[1] and got the same result basically.

      Thanks,
      Dave

      Comment


        #4
        Hello DavidParkins,

        To set the min to a variable so it can be used later you would need to do that from set 1 with the entry.

        In the Inputs and Variables screen make a double variable named myMin.

        In set 1's actions add a new action of -> Misc -> Set myMin

        Hover the mouse over the value and click Set

        Select Indicators -> Min and configure it as needed

        When your entry is submitted the MIN will be saved from that point in time.

        In set 2 where you have used MIN(Low... you would instead use myMin variable as the price.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        9 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        8 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X