Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPriceChange, Getting Too many Entries per direction!

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

    OnPriceChange, Getting Too many Entries per direction!

    Hello, my name is Roberto.

    Im trying to make a strategy based on the following context:

    If the Volume of Candle [0] is twice as big of Candle[1], in that precise moment EnterLong.

    I have managed to accomplish this, by changing the Calculate. OnPriceChange. But the issue that Im having is that the Entry does 5 or six times in the same candle. Because once the position gets filled then it enters another position in the same candle and I wish only to enter one time in the candle.

    (Im guessing that once it went above twice of the last candle, every time it goes higher is twice as last candle!!! But not sure!.)

    Can you please Help me out


    Calculate = Calculate.OnPriceChange;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.UniqueEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.ImmediatelySubmit;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;


    This is What I have on settings!.

    #2
    Hello RobertoPaez,

    Thank you for your post.

    You'd want to use BarsSinceEntryExecution to control whether it can enter again in the same bar:

    https://ninjatrader.com/support/help...yexecution.htm

    Here's a simple example:

    Code:
    protected override void OnBarUpdate()
    {
        if (CurrentBar < BarsRequiredToTrade)
            return;
    
        // Only enter if at least 10 bars has passed since our last entry or we have not yet entered, and our cross condition is true
        if ((BarsSinceEntryExecution() > 10 || BarsSinceEntryExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
            EnterLong();
    
    }
    In your case, since you only want to enter if it's not the same bar as the previous entry, you'd want to use:

    if ((BarsSinceEntryExecution() >= 1 || BarsSinceEntryExecution() == -1) && //additional conditions go here)

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Cross161, Today, 10:33 PM
    0 responses
    2 views
    0 likes
    Last Post Cross161  
    Started by neilzep, Today, 08:55 PM
    0 responses
    5 views
    0 likes
    Last Post neilzep
    by neilzep
     
    Started by javier.filgueira, Today, 03:29 PM
    3 responses
    10 views
    0 likes
    Last Post javier.filgueira  
    Started by Da vinci, Today, 03:15 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by Da vinci, Today, 02:51 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X