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 NullPointStrategies, Today, 05:17 AM
        0 responses
        48 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        66 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X