Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Comparision

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

    Price Comparision

    Hi all,

    I am going to compare current price with my previous entry price.
    Example>:

    If ( RSI < 25 )
    {
    EnterLong;
    }

    If ( CurrentPrice < Previous Entry Price)
    {
    EnterLong;
    }

    For CurrentPrice I can use Close[0], but how can I get previous entry price ?

    Thanks in advance.

    #2
    Hello qzhang119,
    You have to assign an object to your entry orders.

    in variable
    Code:
    IOrder order = null;

    in OnBarUpdate

    Code:
    if (condition)
    {
     order = EnterLong();
    }
    
    if (order != null && Close[0] < order.AvgFillPrice)
    {
       //do something
    }


    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi Joydeep,

      I got a situation such as(ES09-12):
      enterlong $10 @price1;
      enterlong $20 @price2;
      enterlong $30 @price3.

      exitlong ($10 + $20 + $30 @price4);
      ----------------------------------------------------------
      I try to set private int target1 = 10, int target2 = 20, int target3 = 30
      private int totaltarget = 60
      exitlong(totaltarget, "Exit")
      However, get warning that totaltarget is a string, cannot convert to int.

      Could you help me?
      Thanks in Advance.

      Comment


        #4
        Hello qzhang119,
        If you try submitting the exit orders using the below overload then can you successfully submit the orders
        Code:
        ExitLong(int quantity, string signalName, string fromEntrySignal)
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hi Joydeep,

          I use the "ExitLong(int quantity, string signalName, string fromEntrySignal)" style, but what I want here is sum different quantities into a total number to exitlong. For example:
          enter 10 quantity(targetquantity1) at price1;
          enter 10 quantity(targetquantity2) at price2;
          enter 10 quantity(targetquantity3) at price3.

          int totalquantity= targetquantity1+targetquantity2+targetquantity3;

          exitlong(totalquantity, "exitlong");

          but the system shows "totalquantity cannot be converted into int", but I have pre-defined it as:
          private int totalquantity.

          Could you help me?

          Thanks

          Comment


            #6
            Originally posted by qzhang119 View Post
            Hi Joydeep,

            I use the "ExitLong(int quantity, string signalName, string fromEntrySignal)" style, but what I want here is sum different quantities into a total number to exitlong. For example:
            enter 10 quantity(targetquantity1) at price1;
            enter 10 quantity(targetquantity2) at price2;
            enter 10 quantity(targetquantity3) at price3.

            int totalquantity= targetquantity1+targetquantity2+targetquantity3;

            exitlong(totalquantity, "exitlong");

            but the system shows "totalquantity cannot be converted into int", but I have pre-defined it as:
            private int totalquantity.

            Could you help me?

            Thanks
            Your syntax is wrong.

            If you want to simply go flat, use ExitLong(), and the quantity is irrelevant; you will simply exit everything, no matter how many contracts.

            If you want to control the number, then use ExitLong(totalquantity).

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            67 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            36 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            60 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            62 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            53 views
            0 likes
            Last Post CarlTrading  
            Working...
            X