Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scaling In Help Needed

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

    Scaling In Help Needed

    Hi,

    I could use some help getting my “scale in” logic to work correctly. I’ve taken a look at the example code usually referenced for this sort of problem and I think I still don’t understand everything correctly.
    I do have this working correctly for getting in/out with one entry and need help getting it to work with more than one entry using the “Entries per direction” property.
    “Entry handling” is set to “AllEntries”.
    What is supposed to happen (and what I have working correctly) is an entry after conditions are met and an immediate placement of a profit target order. Exit occurs upon either hitting the profit target or at the market if conditions indicate.
    The part I don’t have working correctly is: If the next bar is against the trade and the market is below the fill price (for a long), then scale into the position.
    I’ve tried to ‘cut and paste’ to isolate the code handling orders as much as possible! The problem is that it doesn’t seem to matter what I set the Entries per direction property to - I don’t seem to be getting any additional entries.
    Thanks so much for your help!
    Here’s some example logic of what I have so far:
    private IOrder entryOrder = null;
    protected override void OnExecution(IExecution execution)
    {
    if (entryOrder != null && entryOrder.Token == execution.Order.Token) {
    // we have an execution to process!
    lastEntryPrice = execution.Order.AvgFillPrice;
    }
    }

    In method OnBarUpdate():

    if (exitlong) {
    ExitLong(signalname);
    entryOrder = null;
    lastEntryPrice = 0.0;
    }

    if (enterlong) {
    signalname = “EntryA”;
    entryOrder = EnterLongLimit(limitprice), signalname);
    lastEntryPrice = 0.0;
    if (!Historical) {
    SetProfitTarget(signalname, CalculationMode.Percent, ptargetpercent);
    }
    }
    else if (Position.MarketPosition == MarketPosition.Long) {
    if(lastEntryPrice > 0.0 && lastEntryPrice > Closes[0][0]-.02) {
    entryOrder = EnterLong(signalname);
    lastEntryPrice = 0.0;
    }

    #2
    Hello,

    I looked at your code breifly and nothing jumped out at me. Try using Print() statements and print out key condition information. You will have to play around with it to see why this is happening, sorry.
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben,

      I think I figured out what was happening.....

      I had order size set to "by account size". When this happens the first entry uses all available capital leaving nothing for subsequent entries.

      What I'd like to have happen is each entry should use Acct Size/Max Entries capital. Do you have a suggestion as to how to set that up?

      Thank you,

      John

      Comment


        #4
        John,

        Use "By strategy" for the "Set order quantity" property and then in your code do the necessary math to submit with the quantity you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          John,

          Use "By strategy" for the "Set order quantity" property and then in your code do the necessary math to submit with the quantity you want.

          Is there a way to use the "virtual" account internal to NT, or do I have to keep track of P&L myself? I did a search for properties/methods to do this in the documentation and couldn't find anything....

          Any help greatly appreciated!

          John

          Comment


            #6
            The use of AccountSize will hand off control completely to NinjaTrader and will max you out quantity for the given account size. If you wanted to do some kind of division on it then you will need to take over the math and do it yourself.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

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