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

Managing Profit target during the night.

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

    Managing Profit target during the night.

    I am taking profit during the day by controling the gains between price paid and current price.
    if (current price- proce paid / pricepaid >= x) exitLomg.
    However, as my system dos not run all night long, I want to leave a profit target order open.
    so, at 155900 I use:
    if(ToTime(Times[0][0])==155900)
    {
    if (Position.MarketPosition == MarketPosition.Long)
    {
    myLongProfitTargetOrder = ExitLongLimit(positionTaken,(priceLong*(1+stopGain Number)));
    }
    if (Position.MarketPosition == MarketPosition.Short)
    {
    myShortProfitTargetOrder = ExitShortLimit(positionTaken,(priceShort/(1+stopGainNumber)));
    }
    at 93200 I cancel myLongProfitTargetOrder and myShortProfitTargetOrder .
    But as I am testing the profit target order is not working (at least on backtesting).
    Is this the right way to leave profit target orders during night?

    #2
    Hello,
    That is one process you could use to submit the order.
    You will need to debug the strategy if you are seeing that it is not submitting the order. using TraceOrders to trace what is occurring with the orders. Please see the following link on TraceOrders: http://ninjatrader.com/support/forum...ead.php?t=3627
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      tracing orders I found out that my profit target orders are canlled after some time..

      'So, i am trying to use.
      myLongProfitTargetOrder = ExitLongLimit(0,true,positionTaken,(priceLong*(1+s topGainNumber)));

      but the compiler is not accepting it. saying that ExitShortLimit (int, double, string...)

      Btw, do I have to use ExitShortLimit to order a profit target?

      Comment


        #4
        Hello,
        The closest overload that you are using is the Advanced Order Handling overload for the ExitShortLimit() order method: ExitShortLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)

        From the code you have provided you are missing arguments for the signalName string and the fromEntrySignal string. To use this overload you will need to add those arguments.

        The ExitShortLimit() is one way to submit a pending limit order. You could also use the SetProifitTarget() method. Please see the following link on the SetProfitTarget() method: http://ninjatrader.com/support/helpG...ofittarget.htm
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          problem solved. thx..

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,229 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          7 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          440 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          12 views
          0 likes
          Last Post FAQtrader  
          Working...
          X