• 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

Not taking trades.

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

    Not taking trades.

    I have this simple code and I tried it live today on a SIM account and it took no trades. Am I doing something wrong here?
    Thanks.

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class MyCustomStrategy3 : Strategy
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "MyCustomStrategy3";
    Calculate = Calculate.OnEachTick;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (GetCurrentBid(0) > High[1])
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (GetCurrentAsk(0) < Low[1])
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    }
    }
    }

    #2
    Hello Trader17,

    I would suggest adding print statements to check whether your conditions are becoming true. I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
    https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

    I’ve provided a link covering debugging which you may find helpful.
    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Not sure if I am doing something wrong. Is there a certain procedure to activate a strategy on the live market on a sim or live account?
      Thanks.

      Comment


        #4
        Try to replace GetCurrentBid with Close[0] instead and see if it helps.

        Test on strategy analyser and see if it picks up any entries there.

        Comment


          #5
          Hello Trader17,

          You would not have to do anything different to active the strategy in sim vs live.

          Please let us know if you need further assistance.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Do I need Chart Trader on the chart open to run the strategy? Not sure it back tests but will not take live trades in live or sim account.
            Thanks.

            Comment


              #7
              Hello Trader17,

              You do not need chart trader to run a strategy.

              Do you see results when running the same test on the SampleMaCrossOver strategy in NinjaTrader with the same settings as your strategy?

              Who are you connected to? This is displayed in green on lower left corner of the Control Center window.

              Are you connected to your data feed provider when running this test?

              What instrument(s) (and expiry if applicable) have you selected?

              What Data Series Type have you selected? Example: Tick, Minute, Day
              What From and To date is selected?

              Is your strategy a multi instrument or multi time frame strategy?

              Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

              I look forward to your reply.
              Last edited by NinjaTrader_AlanP; 08-09-2017, 06:32 AM.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Sorry. Forgot to check Strategy Enabled. Sorry. Am still learning the platform.
                Cheers.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by saltminer, Today, 05:19 PM
                0 responses
                3 views
                0 likes
                Last Post saltminer  
                Started by martyn73, Today, 04:18 PM
                0 responses
                2 views
                0 likes
                Last Post martyn73  
                Started by aprendiz, Today, 03:42 PM
                0 responses
                2 views
                0 likes
                Last Post aprendiz  
                Started by 1001111, Today, 09:10 AM
                1 response
                18 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by usero86, Today, 06:02 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Working...
                X