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

Pyramiding Question

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

    Pyramiding Question

    I am trying to write a simple strategy that buys an N bar high and adds to the position as it moves in my favor. I'm just focusing on getting the entry working for now. The code is as follows:

    if (Close[0] >= MAX(30)[0])
    {
    EnterLong("unit1");
    EnterLongStop(Close[0] + .5* ATR(20)[0], "unit2");
    EnterLongStop(Close[0] + 1.0* ATR(20)[0], "unit3");
    EnterLongStop(Close[0] + 1.5* ATR(20)[0], "unit4");

    }

    What I THINK I am getting is:

    system enters unit 1 long and units 2 and 3 on a stop, the price pulls back slightly, and we have to wait for another 30 bar high before the entry of unit 4 because otherwise the MAX30 condition is no longer being met

    What I am looking for is:

    if the price >= the max price of the last 30 bars
    enter unit 1 long and submit orders for units 2, 3, and 4 on a stop based on the ATR

    What is the solution here? Thanks for your help!
    (image of the above description attached)

    A C# Newb
    Attached Files
    Last edited by Space123; 10-24-2009, 01:34 PM.

    #2
    Space123, from the picture you provided, it looks like your strategy is almost exactly what you are telling it to-other than the entry #4 being way above the other entries.

    You are correct in assuming this is because the conditions are no longer true that caused the entry orders. You will want to use the overload for the entries that specifies orders are liveUntilCancelled (a true/false variable during order submission). This link will take you to the help guide page for EnterLongStop, and there is a brief explanation for liveUntilCancelled.

    There is another variable called TraceOrders that, when set to true, can be an excellent tool to diagnose what could be going wrong with strategies. Here is a link to a post by Josh that explains how to use this tool.

    In short, your EnterLongStop methods will need to be a little longer and more detailed:
    Code:
    // EnterLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName)
    // for entry number 4, you could do this:
    EnterLongStop(0, true, 1, Close[0] + 1.5* ATR(20)[0], "unit4");
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      Thank you kindly for the response. The TraceOrders advice was invaluable and allowed me to get a handle on the problem.

      Regards,

      Ben

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      43 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      25 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Working...
      X