Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi entry (scale in)

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

    Multi entry (scale in)

    Hi friends.

    hope someone can help me .

    i want for each entry signal 1 contract to add on my opsition.
    i have try some thing but i haved find any working solution.

    i work with ninjatrader strategy builder .

    if someone now how to add for each signal a contract more that would be very nice.


    public class BBBands : Strategy
    {
    private NinjaTrader.NinjaScript.Indicators.new.BBbands BBBands1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "BBBands";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlatSynchronizeAccount;
    TimeInForce = TimeInForce.Day;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    Target = 30;
    Stop = 15;
    BBHalf = 66;
    BBDevi = 2.8;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    BBbands = BBbands(Close, Convert.ToInt32(BBHalf), NinjaTrader.Data.PriceType.close, BBdevi, true);
    BBbands1.Plots[0].Brush = Brushes.Red;
    BBbands1.Plots[1].Brush = Brushes.DarkGray;
    BBbands1.Plots[2].Brush = Brushes.Lime;
    BBbands1.Plots[3].Brush = Brushes.Red;
    BBbands1.Plots[4].Brush = Brushes.Lime;
    AddChartIndicator(BBbands1);
    SetStopLoss(CalculationMode.Ticks, Stop);
    SetProfitTarget("", CalculationMode.Ticks, Target);
    }
    }

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

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (BBbands1.BullishMarker[0] != 0))
    {
    ExitShort(Convert.ToInt32(DefaultQuantity), "", "");
    BackBrush = Brushes.Lime;
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (BBbands1.BearishMarker[0] != 0))
    {
    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    BackBrush = Brushes.Crimson;
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 3
    if ((Position.MarketPosition == MarketPosition.Short)
    && (BBbands1.BullishMarker[0] != 0))
    {
    ExitShort(Convert.ToInt32(DefaultQuantity), "", "");
    BackBrush = Brushes.Lime;
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 4
    if ((Position.MarketPosition == MarketPosition.Long)
    && (BBbands1.BearishMarker[0] != 0))
    {
    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    BackBrush = Brushes.Crimson;
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    }

    region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Target", Order=1, GroupName="Parameters")]
    public int Target
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Stop", Order=2, GroupName="Parameters")]
    public int Stop
    { get; set; }

    [NinjaScriptProperty]
    [Range(0, int.MaxValue)]
    [Display(Name="BBHalf", Description="BBbands Einstellung 1", Order=3, GroupName="Parameters")]
    public int BBHalf
    { get; set; }

    [NinjaScriptProperty]
    [Range(0, double.MaxValue)]
    [Display(Name="BBdevi", Description="BBbands Einstellung 2", Order=4, GroupName="Parameters")]
    public double BBdevi
    { get; set; }
    #endregion

    }
    }​​

    #2
    Hello nadire.sadiki60,

    Thanks for your post.

    I see that you are calling Entry methods and Exit methods in the same Set in your strategy. Entry and Exit methods should not be called in the same Set as this could cause issues to occur.

    To reverse the position of a strategy, simply call the Entry order method in the opposite direction as mentioned in the Managed Approach help guide page linked below.

    "Entry() methods will reverse the position automatically. For example if you are in a 1 contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position."

    Managed Approach: https://ninjatrader.com/support/help...d_approach.htm

    Scaling into a position is controlled with the signal names of your strategy, and properties EntryHandling and EntriesPerDirection.

    See this help guide page about Signal Names: https://ninjatrader.com/support/help...m#EntryMethods

    And, see this help guide page about FromSignalName used for Exit methods: https://ninjatrader.com/support/help...CloseAPosition

    This reference sample can help with scaling in and out of a strategy.
    https://ninjatrader.com/suppport/helpGuides/nt8/en-us/scaling_out_of_a_position.htm

    This sample can assist further with managing multiple exit/entry signals:
    https://ninjatrader.com/support/helpGuides/nt8/en-us/using_multiple_entry_exit_sign.htm

    Please let us know if we may be of further assistance to you.​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      thank u very much i wil try it

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      127 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 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