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

BIP for Exit conditions..

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

    BIP for Exit conditions..

    For the following code below for the exit conditions I'm using Index 2, do I need the BIP ==2 in there like I have below, or seeing I designated Highs with Highs[2] already will I not need the BIP in there?

    if(Position.MarketPosition == MarketPosition.Long
    && (BarsInProgress == 2)
    && SMA(Highs[2], fast)[0] < SMA(Highs[2], slow)[1] -.75)

    {
    ExitLong(0, 1, "", "");
    }

    #2
    Hi zachj, you could change the Highs[2] to just High, since you are accessing those series in BIP == 2 context. You can remove the BIP context call as well, however that would change the event timing, so when you statement will be evaluated - currently with the BIP == 2 check in that would be when the second added series calls OnBarUpdate().
    BertrandNinjaTrader Customer Service

    Comment


      #3
      So you say this will change the event timing, what are the consequences of this? I'm still not quite clear. Is it more accurate to use BIP or just have the index worked right into the High ie Highs[2]?

      Comment


        #4
        Well, there's no right or wrong - it depends what you wish to do, on which bars update to act with your code. If you want to act on the BIP == 2 update > then this filter would need to be in the part of code.

        If you just wish to access the data, then accessing High in BIP == 2 context would equal the access of Highs[2] without context.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          To add some light, all I'm really trying to do is make it exit when a lower high is formed on Index 2. Is there any negatives or advantages to use one or the other in this case? Maybe one is slower/faster or something? I did notice it's changes my profit a little bit so there is definately a difference.

          Comment


            #6
            'To add some light, all I'm really trying to do is make it exit when a lower high is formed on Index 2'

            Then I would work in BIP ==2. That's your index 2 update event...
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by r68cervera, Today, 05:29 AM
            0 responses
            2 views
            0 likes
            Last Post r68cervera  
            Started by geddyisodin, Today, 05:20 AM
            0 responses
            3 views
            0 likes
            Last Post geddyisodin  
            Started by JonesJoker, 04-22-2024, 12:23 PM
            6 responses
            34 views
            0 likes
            Last Post JonesJoker  
            Started by GussJ, 03-04-2020, 03:11 PM
            12 responses
            3,239 views
            0 likes
            Last Post Leafcutter  
            Started by AveryFlynn, Today, 04:57 AM
            0 responses
            6 views
            0 likes
            Last Post AveryFlynn  
            Working...
            X