Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Wait x bars after signal to trade

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

    Wait x bars after signal to trade

    Apologies for this simple and probably redundant question. How can I wait x bars after a signal to go long or short, such as from a moving average crossover.

    Thanks

    #2
    first :
    learn C# and NinjaScript
    next :
    create a strategie
    next :
    put this after your strategie setup


    //your signal ...

    if ( ....... == ......)
    {
    signalbar = CurrentBar;
    signal = 1; // long
    }

    if ( ....... == ......)
    {
    signalbar = CurrentBar;
    signal = 2; // short
    }

    int x = 3; // or 4 or 5 or what ever you want

    // trade your signal

    if (signalbar + x == CurrentBar)
    {

    if (signal == 1 && .....)
    {
    orderlong = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, quantity, longlimit, 0, "", "long");
    signal = 0;
    }
    if (signal == 2 && .....)
    {
    ordershort = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, quantity, shortlimit, 0, "", "short");
    signal = 0;
    }


    }

    enjoy
    Last edited by jr123; 12-21-2017, 04:14 AM.

    Comment


      #3
      Hello rgreenberg,

      Thanks for your post.

      I see you have posted a duplicate in the more appropriate Strategy forum. I will provide a response there. https://ninjatrader.com/support/foru...528#post528528

      For future reference please avoid duplicate posts as we do not always see the duplicates. If you have posted in the wrong forum, just let us know and we can move your thread to the correct forum.

      Comment


        #4
        jr123

        Thank you very much for your detailed response! I am very appreciative of you taking the time to respond. I will incorporate your suggestions into my work.

        rg

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        160 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        308 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        349 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X