Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLimitLong and Short

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

    EnterLimitLong and Short

    I did so much research and try all sorts of code but nothing is working. I want the price to enter a limit long or short 30 ticks away. Nothing is working at the moment.

    if (CrossAbove(LinReg1, VWMA1, 1))
    {

    SetStopLoss("LongEntry", CalculationMode.Ticks, stopLossTicks, false);
    SetProfitTarget("LongEntry", CalculationMode.Ticks, takeProfitTicks);​
    EnterLongLimit(1, Close[0] + 30 * TickSize, "LongEntry");
    //EnterLong(Convert.ToInt32(DefaultQuantity), "LongEntry");
    }

    // Set 2
    if (CrossBelow(LinReg1, VWMA1, 1))
    {

    SetStopLoss("ShortEntry", CalculationMode.Ticks, stopLossTicks, false);
    SetProfitTarget("ShortEntry", CalculationMode.Ticks, takeProfitTicks);​
    EnterShortLimit(1, Close[0] + 30 * TickSize, "ShortEntry");
    //EnterShort(Convert.ToInt32(DefaultQuantity), "ShortEntry");
    }​

    #2
    Hello zayone,


    Thank you for your post.


    It is helpful to set TraceOrders to true in State.Configure as well as print the order object in OnOrderUpdate().


    TraceOrders will output to the NinjaScript Output window a message when orders are being submitted, ignored, cancelled, or rejected.


    Printing the order object in OnOrderUpdate() will allow you to track the progression of the order from submitted, to working, to filled, cancelled, or rejected.


    These tools will let you know what happens to the order.


    TraceOrders - https://ninjatrader.com/support/help...raceorders.htm

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm


    I'm also including a link to a forum post with further suggestions on debugging a script.

    https://ninjatrader.com/support/foru...956#post671956


    Save the output from the output window to a text file. Let me know if you need assistance creating a print or enabling TraceOrders.


    Additionally, you may want to set isLiveUntilCancelled to true to keep your orders alive.

    EnterLongStopLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName)


    Please see this sample script from the Help Guide on Keeping order alive using isLiveUntilCancelled:

    https://ninjatrader.com/support/help...ders_alive.htm


    I am happy to assist with analyzing the output from prints and TraceOrders.

    Comment


      #3
      It's weird but when I click those links it gives me a Page Not Found message. Why is that?

      Comment


        #4
        Hello zayone,

        I've corrected the links without hashtag symbols in Gaby's post above.

        With links that have hashtag symbols the issue with the url appears to be common with the forum. Our IT is aware of the issue and is investigating.
        In the meantime, we have had reports using an ad blocker such as uBlock Origin can prevent the malformed Urls.

        ​I am providing the link as text below.
        Code:
        https://ninjatrader.com/support/forum/forum/ninjascript-educational-resources/tips/3527-debugging-your-ninjascript-code?p=671956#post671956
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        54 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        72 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X