Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multiple exit signals

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

    multiple exit signals

    Hi ,
    I have a strategy that generates multiple exit signals, say signal-A & signal-B. I want to partially exit on signal-A & partially on signal-B. Now signal-A can happen multiple times before signal-B, how can i ensure it does not exit all the position quantity on repeating signal-A.

    thanks
    P.S: The script uses multiple instruments & multiple timeframes.
    Last edited by a_c123; 07-13-2015, 12:54 PM.

    #2
    Hello a_c123,

    Add a bool to your script that starts with a false value. When the first condition triggers, set a bool to true. Then require that this bool be false for the first condition to fire.
    After the second condition fires set this bool back to false so that the first condition may trigger again.

    private bool myBool = false;

    if (myBool == false /* && condition 1 conditions here */)
    {
    myBool = true;
    // place first order here
    }

    if (myBool == true /* && condition 2 conditions here */)
    {
    myBool = false;
    // place second order here
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,
      The solution mentioned by you can only be used in case of 1 instrument but my strategy uses multiple instruments. Does ninjatrader have any object where initial order quantity is stored which can be accessed even after partial exit? or in BarsArray can user defined flag be stored ?

      thanks

      Comment


        #4
        Hello a_c123,

        This solution will work for multiple instruments and time frames.

        It would require that the bool be flipped during the correct bars in progress.


        You can save the quantity to an int object in C#.
        http://www.dotnetperls.com/int

        You can also access the IOrder to find the quantity.
        IOrder myOrder;

        myOrder = EnterLong(5);

        Print(myOrder.Quantity);


        The last part of you message I am not understanding. "or in BarsArray can user defined flag be stored ? ", can you clarify this for me?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello ChelseaB,
          Say i am holding positions in 5 different instruments, the signal-A for each of them will trigger at different times. Now when signal-A triggers for 1st instrument the bool would be set, then the signal-A for 2nd instrument triggers for 1st time but the bool is already set so it will go into wrong code block and so on.

          BarsArray stores data for different instruments/objects, so if it allows to store user defined data we can use it for storing bool flag for each instrument.

          thanks
          Last edited by a_c123; 07-13-2015, 05:04 PM.

          Comment


            #6
            Hello a_c123,

            Thank you for your response.

            If I understand your inquiry correctly, you could simply create a bool for each instrument. There would not be a way to tie it to the BarsArray for the instrument, you would just need to update the bool for each instrument using your own logic.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by xiinteractive, 04-09-2024, 08:08 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Johnny Santiago, 10-11-2019, 09:21 AM
            95 responses
            6,193 views
            0 likes
            Last Post xiinteractive  
            Started by Irukandji, Today, 09:34 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by RubenCazorla, Today, 09:07 AM
            1 response
            6 views
            0 likes
            Last Post RubenCazorla  
            Started by TraderBCL, Today, 04:38 AM
            3 responses
            26 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X