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

strategy works on 5 second timeframe but not on 1 seocnd timeframe

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

    strategy works on 5 second timeframe but not on 1 seocnd timeframe

    please refer to attachment instead of asking forerror etc… much easier that way. But my strategy works on all timeframe inclunding 5 second until i switch it to 1 second and i dont understand why?

    #2
    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class Test : Strategy
    {
    private double StopLong;

    private MIN MIN1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "Test";
    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;
    StopLong = 1;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    MIN1 = MIN(Low, 3);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Close[1] > Open[1])
    && (Position.MarketPosition == MarketPosition.Flat)
    // Condition group 1
    && ((BarsSinceExitExecution(0, "", 0) == -1)
    || (BarsSinceExitExecution(0, "", 0) > 1)))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"EntryLong");
    StopLong = MIN1[0];
    }

    // Set 2
    if (Position.MarketPosition == MarketPosition.Long)
    {
    ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), StopLong, @"StopLong", @"EntryLong");
    ExitLongLimit(Convert.ToInt32(DefaultQuantity), (Position.AveragePrice + (15 * TickSize)) , @"ProfitLong", @"EntryLong");
    }

    }
    }
    }

    region Wizard settings, neither change nor remove
    /*@​

    Comment


      #3
      Hello traderqz,

      Thank you for your post.

      It looks like you have already started a topic for this inquiry: https://forum.ninjatrader.com/forum/...-and-stop-loss

      We do kindly ask that you refrain from creating multiple support cases for the same inquiry, as this duplicates our support efforts and reduces our team's availability to assist all clients in a timely and efficient manner.
      ​​
      If you need assistance for the same inquiry, please reply to the original post instead of starting a new thread.
      Gaby V.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Christopher Leggit, Today, 12:04 AM
      0 responses
      4 views
      0 likes
      Last Post Christopher Leggit  
      Started by Carmelisak, Yesterday, 11:22 PM
      0 responses
      2 views
      0 likes
      Last Post Carmelisak  
      Started by unpronounceable1700, Yesterday, 10:35 PM
      0 responses
      8 views
      0 likes
      Last Post unpronounceable1700  
      Started by milfocs, Yesterday, 09:16 PM
      0 responses
      1 view
      0 likes
      Last Post milfocs
      by milfocs
       
      Started by Mr.Hamster, 08-04-2022, 11:40 AM
      7 responses
      193 views
      1 like
      Last Post 286000
      by 286000
       
      Working...
      X