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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            61 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X