Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Targets...

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

    Setting Targets...

    Hello...just downloaded the new beta version...and i was wondering if someone can help with setting a daily target.

    ...i want to have a daily target of 5 points: and when it's reached: i want my automated trading to close all orders for the day and stop trading.

    i don't know how to write a code...but in the strategy wizard i made an if - then condition: example: if my realized PnL is less than 5, only then the order is the entered. but its not working...is there any way i can set my daily targets?

    thank for your time,
    Samuel

    #2
    Unfortunately this is not possible in the strategy wizard. You would have to manually program this.
    RayNinjaTrader Customer Service

    Comment


      #3
      what do you mean by manually program? do i have to write my own code or manually shut off ninja trader automation when the target is reached?

      if it can be done by a code: can you give me an idea of where i can read about developing it or if you have one as i reference, that would help also.


      thanks.

      Comment


        #4
        Sorry, I mean actually programming the code. Please see our Help Guide section "NinjaScript" there is a wealth of information there.
        RayNinjaTrader Customer Service

        Comment


          #5
          thanx, i found a few good references. and i been trying to get this bottom code to work, but its not working at all. (I basically want to stop trading after 6 points is reached). what am i doing wrong?


          thank you so much for your time


          if ((Performance.AllTrades.TradesPerformance.Points.C umProfit + Position.GetProfitLoss(Close[0],PerformanceUnit.Points) >= 6))
          {
          StopStrategy();
          return;
          }
          }
          privatevoid StopStrategy()
          {
          {
          // If our Long Limit order is still active we will need to cancel it.
          CancelOrder(EnterLong(DefaultQuantity, ""));
          CancelOrder(EnterShort(DefaultQuantity,
          ""));

          // If we have a position we will need to close the position
          if (Position.MarketPosition == MarketPosition.Long)
          ExitLong();
          elseif (Position.MarketPosition == MarketPosition.Short)
          ExitShort();
          }
          }

          Comment


            #6
            Please describe what you are currently experiencing. CancelOrders() doesn't work unless you pass in an IOrder object. The IOrder object you pass in must match the order you want to cancel. You are currently passing in an Enter() method and that won't work to cancel orders that are currently active.

            There are several approaches you can take to achieve what you want. Please take a look at the following reference samples: http://www.ninjatrader-support.com/v...ead.php?t=4084
            Last edited by NinjaTrader_JoshP; 03-06-2008, 12:10 AM.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              thank you so much i put an iOrder in and now its works!. But its works when i backtest it, but when i am trying to execute live - its doesn't do anything.

              i have the strategy selected on the chart and i am connnected to a live feed...but the strategy doesn't work live. Although it works when i back test it...any way i can get this to work to live?

              Comment


                #8
                You would need to debug your strategy to see why its not working in real-time. In case you have not seen it, here is a reference on some debugging ideas.

                RayNinjaTrader Customer Service

                Comment


                  #9
                  thanx Ray...after i commented out this section, its working fine. Can you tell me what's wrong this part:

                  //if (Performance.AllTrades.TradesPerformance.Currency. CumProfit > 50
                  //|| Performance.AllTrades.TradesPerformance.Currency.C umProfit < -150)
                  //{
                  // StopStrategy();
                  // return;
                  //}

                  Comment


                    #10
                    I can tell you the syntax looks correct.
                    I can't tell you why this would not make your strategy behave as expected.
                    You will need to debug it.
                    RayNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

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