• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

entry after X tick from a signal

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

    entry after X tick from a signal

    hello,
    strategy looks for a signal. After that it should enter X tick from the signal ( say -10 tick from entry). it doesn't work because trades entry on the signal but not after x tick.
    I hope some good soul suggests me something.
    Thank you in advance and sorry for my poor english.

    {
    // Condition set 1
    if (Close[0] > EMA(14)[0])
    {double signal =Close[0];
    double tick = Close[0]-10*TickSize;
    double entry = Close[0]-tick;

    if(Close[0] < entry)
    {EnterLong();}

    }

    #2
    Hello zteck,

    Thank you for your note.

    I noted that the entry condition is inside of the condition setting the signal, because this is within another condition it may not become true frequently. Is this what you had intended?

    I look forward to being of further assistance.
    Chris Sch.NinjaTrader Customer Service

    Comment


      #3
      Hello Chris Sch,
      if (Close[0] > EMA(14)[0]) gives me the the first condition but not the entry. The trade should enter when price gets over of 10 ticks from the first condition ( if (Close[0] > EMA(14)[0])) so when if(Close[0] < entry).

      Comment


        #4
        as Jesse suggested me ( Thank to Jesse ), the right code is:
        private double entry
        *******************************
        if(Close[0]>EMA(14)[0] )

        {

        entry = Close[0] - 10 * TickSize;

        }

        if(Math.Abs( Close[0]- entry) < 0.0001)
        {
        EnterLong();
        }

        however, This code takes in account every event. every Close over EMA makes a new condition so the entry calculation
        ( Close[0]- entry ) happens for every Close over EMA. I would The calculation happens just when the first bar satisfied the entry condition
        ( entry = Close[0] - 10 * TickSize; ). the set up should turn off and look for a new condition when price crosses below the ema.
        A bool variable could works well for that. Have you got any suggestion for solve the calculation just for the first bar?
        Thank you in advance again!

        Comment


          #5
          Hello zteck,

          Thank you for your note.

          You could certainly utilize a bool in this situation that would be changed to true, for example, when the condition is met. Depending on the rest of your logic, you could also opt to use a MarketPosition if statement that will only execute if flat.

          I've provided a link to the MarketPosition page of our Help Guide for more information: http://ninjatrader.com/support/helpG...etposition.htm

          Please don't hesitate to reach out again if further questions come up.
          Chris Sch.NinjaTrader Customer Service

          Comment


            #6
            Thank you for the reply. The first great problem for me is to try to get the Close of the first bar when strategy meets the condition ( Close[0]>EMA(14)[0]. Indeed, after the first bar, strategy meets the same condition with other bars so the entry shift down because is linked to the last condition met. but I'm interested to the first bar that makes the first condition.
            Last edited by zteck; 08-21-2017, 03:46 PM.

            Comment


              #7
              Hello zteck,

              Thank you for the reply.

              I am unsure if I understand what you are asking. Are you wanting to retrieve the Close price for the first bar that meets your condition? You could add a Print statement within the bracketed condition such as:

              Print("The high of the current bar is : " + Close[0]);
              //Output: The close of the current bar is : 2112.75

              Again, if you utilize a bool or a MarketPosition if statement then you will be able to ensure that this only executes once for the first time the condition is met.

              Please let us know if we may provide further assistance.
              Chris Sch.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by guvenators, Today, 05:18 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by LANwarr1or, Today, 03:00 PM
              2 responses
              8 views
              0 likes
              Last Post LANwarr1or  
              Started by Newtrader101, Today, 02:53 PM
              2 responses
              10 views
              0 likes
              Last Post Newtrader101  
              Started by JuanPabloQuevedo, Today, 02:53 PM
              2 responses
              9 views
              0 likes
              Last Post JuanPabloQuevedo  
              Started by samir, Today, 03:16 PM
              2 responses
              14 views
              0 likes
              Last Post samir
              by samir
               
              Working...
              X