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

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:



    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 Haiasi, 04-25-2024, 06:53 PM
    2 responses
    17 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    5 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,408 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Working...
    X