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

Bars since Exit not working

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

    Bars since Exit not working

    Hi, I am trying to create a simple crossover strategy in Strategy Builder where another trade won't be entered for at least 10 bars after a previous exit.

    I have read several tutorials, and tried several methods for accomplishing this but still trades are either executed every time the crossover occurs even if it's less than 10 bars since the previous, or no trades are made.

    When I use signal names, no trades are executing.
    When I don't use signal names, all trades are executing.

    Below are my settings.

    I am also using a Trailing Stop. I'm not sure if that needs updating as well.
    .
    Can you please help me with what I'm doing wrong? Thank you,

    Mitch

    Click image for larger version  Name:	image.png Views:	0 Size:	40.7 KB ID:	1298034
    Click image for larger version  Name:	image.png Views:	0 Size:	34.7 KB ID:	1298035
    Click image for larger version

Name:	image.png
Views:	18
Size:	37.1 KB
ID:	1298044
    ​​
    Last edited by mmenigma; 04-02-2024, 08:52 AM.

    #2
    Hello mmenigma,

    Thank you for your post.

    If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true and the order is not being submitted, or the order is being ignored for other reasons, or the order is being cancelled.

    To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    I am happy to assist you with analyzing the output from the output window.

    Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Below is a link to a forum post that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


    Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print or enabling TraceOrders.​


    I would also like to note, if no trades are made, it is possible the order is being ignored since I see you are using both exit and set methods in your script. From the Help Guide:

    "Methods that generate orders to exit a position will be ignored if:
    • A position is open and an order submitted by a set method (SetStopLoss() for example) is active​
    Set() methods that generate orders to exit a position will be ignored if:
    • A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active​"
    https://ninjatrader.com/support/help...d_approach.htm



    I recommend using prints and TraceOrders to confirm what is going on with the behavior of the strategy.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by llanqui, 04-28-2024, 10:32 AM
    2 responses
    16 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by DroneBlackCa, Today, 05:17 AM
    0 responses
    2 views
    0 likes
    Last Post DroneBlackCa  
    Started by tradingnasdaqprueba, 04-09-2024, 09:52 AM
    7 responses
    49 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by deamenvc, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post deamenvc  
    Started by r68cervera, Today, 04:45 AM
    0 responses
    5 views
    0 likes
    Last Post r68cervera  
    Working...
    X