Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem setprofitTarget...is correct?

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

    Problem setprofitTarget...is correct?

    hi, see pics 1

    In A ..i enter 9550 long and target profit 10300

    In B . i enter 9550 short and Stop 9570..

    if i use this code .

    Code:
         SetStopLoss(CalculationMode.Price, main.().StopFc);
                        SetProfitTarget(CalculationMode.Price, main.().Tp);
    in pics 2 you see the problem:

    In trade B it stop trade A(profit target) and execute sell short (trade B)

    No..i don't want stop first operation ..Why it run Profit target ?
    it will be correct sell short and buy it .......
    i don't want that it run: Profit target - Sell short - Buy.....

    in this way i've lost the first trade.....instead i want to take profit the Trade A to 10300..
    Attached Files
    Last edited by turbofib; 09-10-2016, 12:04 PM.

    #2
    Hello turbofib,

    Thanks for your post.

    We recommend that you debug your strategy using print statements to understand why you are getting the executions that you are.

    Here is a link to out tips that will help you in the debug process: http://ninjatrader.com/support/forum...ead.php?t=3418
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello turbofib,

      Thanks for your post.

      We recommend that you debug your strategy using print statements to understand why you are getting the executions that you are.

      Here is a link to out tips that will help you in the debug process: http://ninjatrader.com/support/forum...ead.php?t=3418
      You don't understand my problem
      Can you read another time my post please

      Comment


        #4
        it's the summary of trade:

        Trade A : Long tp 9550

        Trade B short 9550 stop 9570


        My strategy run :

        -Long 9550

        -Profit Target 9461.5

        -Sell short 9461.5

        -Buy 9544.5

        ...
        ...

        I DON'T WANT to execute Profit Target 9461.5



        i want that it run in following order:



        -Long 9550

        -Sell short 9461.5

        -Buy 9544.5
        ...
        ...

        my Strategy:

        Code:
           main.Update();
                    if (main.Mp.Count_Conferma ==0 )
                        return;
                    if (lastSignal != main.Mp.TargetSchieraConfermati.Last().numBar)
                    {
                        lastSignal = main.Mp.TargetSchieraConfermati.Last().numBar;
                        if (main.Mp.TargetSchieraConfermati.Last().upDown)
                        {
                            EnterLong();
                            SetStopLoss(CalculationMode.Price, main.Mp.TargetSchieraConfermati.Last().StopFc);
                            SetProfitTarget(CalculationMode.Price, main.Mp.TargetSchieraConfermati.Last().TpFinale);
        
                        }
                        else EnterShort();
                        {
                            SetStopLoss(CalculationMode.Price, main.Mp.TargetSchieraConfermati.Last().StopFc);
                            SetProfitTarget(CalculationMode.Price, main.Mp.TargetSchieraConfermati.Last().TpFinale);
        
                        }
                    }
        In class main i get signal in real time..
        if (lastSignal != main.Mp.TargetSchieraConfermati.Last().numBar) ===> here i check if there is new signal..
        if there is new signal i set Long or Short And SetStopLoss and SetProfitTarget


        Do you understand now my problem?
        Last edited by turbofib; 09-13-2016, 01:44 AM.

        Comment


          #5
          Hello turbofib,

          Thank you for your post.

          You cannot go short while still long without expecting to see the Profit Target moved down to close the long position.

          If you want to go long and go short, us two different strategies, one for short and one for long.

          Just to clarfiy, you cannot go long and short at the same time in a Managed NinjaScript Strategy. Technically you can't go long and short at the same time in one market on the same account.

          Comment


            #6
            ok..i understand....

            But if my strategy allows me to entry with more signal on the same direction,
            i try it but It does not do more than one contract at a time

            what am I wrong? (i mean to entry in the same direction )

            https://gyazo.com/4c8eab58da64d1c71895f6967810c5d9 (pics of my setting)

            Code strategy


            protected override void OnBarUpdate()
            {
            main.Update();
            if (main.Mp.Count_Conferma ==0 )
            return;
            if (lastSignal != main.Mp.TargetSchieraConfermati.Last().numBar)
            {
            lastSignal = main.Mp.TargetSchieraConfermati.Last().numBar;
            if (main.Mp.TargetSchieraConfermati.Last().upDown)
            {
            string stringLongSignal = "L" + CurrentBar.ToString();
            EnterLong(1, stringLongSignal);
            SetStopLoss(stringLongSignal,CalculationMode.Price , main.Mp.TargetSchieraConfermati.Last().StopFc,true );
            SetProfitTarget(stringLongSignal,CalculationMode.P rice, main.Mp.TargetSchieraConfermati.Last().TpFinale);

            }
            else
            {
            string stringShortSignal = "S" + CurrentBar.ToString();
            EnterShort(1, stringShortSignal);
            SetStopLoss(stringShortSignal,CalculationMode.Pric e, main.Mp.TargetSchieraConfermati.Last().StopFc,true );
            SetProfitTarget(stringShortSignal,CalculationMode. Price, main.Mp.TargetSchieraConfermati.Last().TpFinale);

            }
            }
            }

            Comment


              #7
              Hello turbofib,

              Thank you for your patience.

              You would need to set the EntriesPerDirection to the desired number of entries. Currently you have this set to 1.

              For information on EntriesPerDirection please visit the following link: http://ninjatrader.com/support/helpG...rdirection.htm

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by junkone, Today, 11:37 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by frankthearm, Yesterday, 09:08 AM
              11 responses
              43 views
              0 likes
              Last Post frankthearm  
              Started by quantismo, 04-17-2024, 05:13 PM
              5 responses
              35 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by proptrade13, Today, 11:06 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              35 views
              0 likes
              Last Post love2code2trade  
              Working...
              X