Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleScaleOut Strategy

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

    SampleScaleOut Strategy

    Hi,

    Having looked at the SampleScaleOut Strategy, I tried to implement this in my strategy, which is to buy 4 contracts and then sell one at each defined target, however the strategy only seems to do the first "buy". Any ideas?

    EnterLong("Buy1");
    EnterLong(
    "Buy2");
    EnterLong(
    "Buy3");
    EnterLong(
    "Buy4");
    longCount=
    1;
    SetProfitTarget(
    "Buy1", CalculationMode.Price, targetAValue);
    SetProfitTarget(
    "Buy2", CalculationMode.Price, targetBValue);
    SetProfitTarget(
    "Buy3", CalculationMode.Price, targetCValue);
    SetProfitTarget(
    "Buy4", CalculationMode.Price, targetDValue);


    #2
    Ensure you have changed the EntriesPerDirection setting when you start up your strategy to 4.

    Also, be aware that you need to call SetProfitTarget() and SetStopLoss() before you do EnterLong if you want those to attach to this current trade.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      RE:

      protectedoverridevoid Initialize()
      {
      EntriesPerDirection =
      4;
      EntryHandling = EntryHandling.UniqueEntries;
      Add(GartleyRobotBull(
      5, 2, 65));
      SetStopLoss(CalculationMode.Ticks ,
      20);
      //CalculateOnBarClose = true;
      //Add(PeriodType.Minute, 1);
      }

      Sorry, I should have included the above bit. My EntriesPerDirection is set to 4 and I am still only getting the first buy. Any other ideas?

      Thanks for the order info, I have now changed it to ...

      SetProfitTarget("Buy1", CalculationMode.Price, targetAValue);
      SetProfitTarget(
      "Buy2", CalculationMode.Price, targetBValue);
      SetProfitTarget(
      "Buy3", CalculationMode.Price, targetCValue);
      SetProfitTarget(
      "Buy4", CalculationMode.Price, targetDValue);
      EnterLong(
      "Buy1");
      EnterLong(
      "Buy2");
      EnterLong(
      "Buy3");
      EnterLong(
      "Buy4");

      Comment


        #4
        Set TraceOrders = true and see what it says.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Nice feature

          From what I can see and what I have looked up, I am getting Exceeded entry signals errors, which indicate that the
          EntriesPerDirection is not set to 4, but it is set to 4. Can it be because I have Calculateonbarclose REMARKED out or do you have another suggestion?

          EntriesPerDirection = 4;
          EntryHandling = EntryHandling.UniqueEntries;
          Add(GartleyRobotBull(
          5, 2, 65
          ));
          SetStopLoss(CalculationMode.Ticks ,
          20
          );
          //CalculateOnBarClose = true;


          13/01/2009 16:30:00 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Buy4' Mode=Price Value=8481.12880468 Currency=0 Simulated=False
          13/01/2009 16:30:00 Entered internal PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy1' FromEntrySignal=''
          13/01/2009 16:30:00 Entered internal PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy2' FromEntrySignal=''
          13/01/2009 16:30:00 Ignored PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy2' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/01/2009 16:30:00 Entered internal PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy3' FromEntrySignal=''
          13/01/2009 16:30:00 Ignored PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy3' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/01/2009 16:30:00 Entered internal PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy4' FromEntrySignal=''
          13/01/2009 16:30:00 Ignored PlaceOrder() method at 13/01/2009 16:30:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy4' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

          Comment


            #6
            Ensure when you run the strategy you did not have the settings in the Strategy Dialogue window override the settings you have programmed.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I can't see anything that cancels out

              I have looked through it and tried remming out a few things and moving the Add above EntriesPerDirection, but nothing seems to work. Can it have something to do with EntryHandling, does this need to be adjusted for multiple entries or is what I have below correct?

              Here is the code ...

              protected
              overridevoid Initialize()
              {
              EntriesPerDirection =
              4;
              EntryHandling = EntryHandling.UniqueEntries;
              Add(GartleyRobotBull(
              5, 2, 65));
              SetStopLoss(CalculationMode.Ticks ,
              20);
              TraceOrders =
              true;
              //CalculateOnBarClose = true;
              //Add(PeriodType.Minute, 1);
              }

              protectedoverridevoid OnBarUpdate()
              {
              if (Position.MarketPosition == MarketPosition.Flat)
              {
              if(entryAValue != GartleyRobotBull(5, 2, 65).EntryA)
              {
              entryAValue = GartleyRobotBull(
              5, 2, 65).EntryA;
              entryBValue = GartleyRobotBull(
              5, 2, 65).EntryB;
              targetAValue = GartleyRobotBull(
              5, 2, 65).TargetA;
              targetBValue = GartleyRobotBull(
              5, 2, 65).TargetB;
              targetCValue = GartleyRobotBull(
              5, 2, 65).TargetC;
              targetDValue = GartleyRobotBull(
              5, 2, 65).TargetD;
              longCount =
              0;
              }
              }
              //if ((Lows[1][1] > storeValue)
              // && (Lows[1][0] <= storeValue)
              //EnterLong(1, 1, "Long: 1min");
              if ((Low[1] > entryAValue)
              && (Low[
              0] <= entryAValue)
              && (Low[
              0] >= entryBValue)
              && (longCount ==
              0))
              {
              SetProfitTarget(
              "Buy1", CalculationMode.Price, targetAValue);
              SetProfitTarget(
              "Buy2", CalculationMode.Price, targetBValue);
              SetProfitTarget(
              "Buy3", CalculationMode.Price, targetCValue);
              SetProfitTarget(
              "Buy4", CalculationMode.Price, targetDValue);
              EnterLong(
              "Buy1");
              EnterLong(
              "Buy2");
              EnterLong(
              "Buy3");
              EnterLong(
              "Buy4");
              longCount=
              1;
              Print(Time +
              " : " + targetBValue + " : " + Position.AvgPrice);

              }
              }

              Comment


                #8
                traderT,

                I am talking about the Strategy Dialogue window, not your code.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Strategy Dialog window?

                  Where do I find the Strategy Dialog window?

                  Comment


                    #10
                    Sorry, found it

                    Sorry, found it and that worked. How can I get my ninjascript to overwrite the Strategy Dialog window?

                    Comment


                      #11
                      I think I have answered that as well

                      It didn't take my ninjacript settings because I refreshed the strategy, rather than reloaded it.

                      Comment


                        #12
                        Great you got it solved traderT!

                        Comment


                          #13
                          Order to Open

                          Is there an order type that I can enter at a certain level, rather than waiting for the next bar? ie, In real life when my indicator gives me an entry level, I create an "order to open" at the level and as soon as the level is reached, a buy order is generate at that level?

                          Comment


                            #14
                            Sure, you could for example use a limit order to place an order at a certain price level - http://www.ninjatrader-support.com/H...LongLimit.html

                            Comment


                              #15
                              But can it do this?

                              Thanks for the reply NT_Bertrand, I had a look at the example and put something together, however, like most times, it didn't do what it was supposed to.

                              Here is a bit of my code ...
                              What I am trying to achieve is for an enterlonglimit (at entryAValue) order being submitted when the first if is true. When the market pulls back to the entryALevel, then the order then fires at the entryALevel. From the things that I have tried, the order still seems to fire the bar after the entryALevel is pierced, and this is not what I want or what you said with regards to using the EnterLongLimit. Any ideas on what I need to change to make this happen?

                              protectedoverridevoid OnBarUpdate()
                              {
                              //if (Position.MarketPosition == MarketPosition.Flat)
                              if(entryAValue != GartleyRobotBull(5, 2, 65).EntryA)
                              {
                              entryAValue = GartleyRobotBull(
                              5, 2, 65).EntryA;
                              entryBValue = GartleyRobotBull(
                              5, 2, 65).EntryB;
                              targetAValue = GartleyRobotBull(
                              5, 2, 65).TargetA;
                              targetBValue = GartleyRobotBull(
                              5, 2, 65).TargetB;
                              targetCValue = GartleyRobotBull(
                              5, 2, 65).TargetC;
                              targetDValue = GartleyRobotBull(
                              5, 2, 65).TargetD;
                              longCount =
                              0;
                              }

                              if(longCount ==0)
                              {
                              EnterLongLimit(entryAValue,
                              "Buy1");
                              SetProfitTarget(
                              "Buy1", CalculationMode.Price, targetAValue);
                              longCount=
                              1;
                              Print(Time +
                              " : " + entryAValue + " : " + longCount);
                              }
                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sjsj2732, Yesterday, 04:31 AM
                              0 responses
                              39 views
                              0 likes
                              Last Post sjsj2732  
                              Started by NullPointStrategies, 03-13-2026, 05:17 AM
                              0 responses
                              289 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              289 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              135 views
                              1 like
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              96 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Working...
                              X