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

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:
    Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


    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, 07: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 mjairg, 07-20-2023, 11:57 PM
                3 responses
                213 views
                1 like
                Last Post PaulMohn  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                4 responses
                544 views
                0 likes
                Last Post PaulMohn  
                Started by GLFX005, Today, 03:23 AM
                0 responses
                3 views
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                12 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                7 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Working...
                X