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.
      Paul H.NinjaTrader Customer Service

      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 Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,769 views
        0 likes
        Last Post Leafcutter  
        Started by Rapine Heihei, 04-23-2024, 07:51 PM
        2 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        943 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        10 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        7 views
        0 likes
        Last Post rocketman7  
        Working...
        X