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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            650 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            577 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X