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 trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    22 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Started by guillembm, Yesterday, 11:25 AM
    2 responses
    9 views
    0 likes
    Last Post guillembm  
    Started by junkone, 04-21-2024, 07:17 AM
    9 responses
    70 views
    0 likes
    Last Post jeronymite  
    Started by mgco4you, Yesterday, 09:46 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X