Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    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.

          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.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by martin70, 03-24-2023, 04:58 AM
              14 responses
              105 views
              0 likes
              Last Post martin70  
              Started by TraderBCL, Today, 04:38 AM
              0 responses
              2 views
              0 likes
              Last Post TraderBCL  
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              606 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              4 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Working...
              X