Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not > or < but if it "touches" then do X if current position is less than Y as well

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

    Not > or < but if it "touches" then do X if current position is less than Y as well

    Hey guys:

    Re: Not > or < but if it "touches" then do X if current position is less than Y as well.

    I am looking to do the following if this condition exists on a current trade/position:

    Right now I have
    Code:
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > 33*TickSize
    as part of the conditions to exit the trade. So, if the other conditions are meet as well as the above, then it exits. I like its performance, but would like to enhance it to do the following:

    If the current trade or position ever "touches"/"reaches" (however you want to say it) being positive 33 ticks in profit & the current ticks in profit is less than 66 ticks, and the other conditions are meet, then exit.

    This way, if it just touches being profitable by 33 ticks then it would qualify as the condition being meet even if the trades begins to drop down below 33 ticks in profit afterwards as long as the current ticks in profit is less than 66 ticks.

    Anyone with input or help would be great...



    Greg
    Last edited by birdog; 10-31-2013, 03:12 PM.

    #2
    Hello Greg,

    Thank you for your post.

    You can set a variable that would be set to true or 1 for example when the Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > 33*TickSize.

    So for example:
    Code:
    if(Position.MarketPosition == MarketPosition.Flat)
    myBool = false;
    if(Position.MarketPosition != MarketPosition.Flat && Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > 33*TickSize)
    myBool = true;
    Then check that myBool is true in your condition.

    Please let me know if you have any questions.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello Greg,

      Thank you for your post.

      You can set a variable that would be set to true or 1 for example when the Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > 33*TickSize.

      So for example:
      Code:
      if(Position.MarketPosition == MarketPosition.Flat)
      myBool = false;
      if(Position.MarketPosition != MarketPosition.Flat && Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > 33*TickSize)
      myBool = true;
      Then check that myBool is true in your condition.

      Please let me know if you have any questions.
      Thanks Patrick...

      Hmm...what if it is true and touches or crosses >33 ticks but then goes back to below or <33 ticks. The condition would be initially true and then later false though doing that right? I am kindof looks for it to recognize that it had touched or crossed >33 and would want to have it remain as if it is True even if it drops below <33 --- and need to tell it to only be true if it is below <66 (if it even does go >than 33 as well during the trade. However, if the trade never ever reaches at least >33 ticks then this would not be applicable or triggered at all (only a separate set initial conditions not related to these would take precedence until it touches at least 33 ticks).

      Also, the reason for the <66 (in the 1st stage) is that once the trade goes above that level then this condition would be disabled/rendered null and void and a new similar set of conditions for the next step up or stage similar to the above (just with different numbers). It goes on like that for 3 stages total.

      ...any ideas on that?

      So, all of your code you set as a sample is intended only for including in the Variables section? Then, I need to refer to it in the On BarUpdate?

      Please let me know and if you have a moment to help out with the above and exactly where to put the code snippets would be great...smile.

      Others welcome to input knowledge on this...

      Comment


        #4
        HI Birdog,

        If I am following you correctly, you want to set this up with a range check for when you are greater than 33 but less than 66 ticks. Your explanation sounds like you have the logic down.

        So, all of your code you set as a sample is intended only for including in the Variables section? Then, I need to refer to it in the On BarUpdate?

        The myBool will be declared in the variables and yes to the second question.
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X