Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different Exit Times + Bool

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

    #16
    Hello Chelsea,

    thank you, I had changed its, and the compiling works

    But the fix exit times has no effect: if bool is on or off makes no difference.

    I changed to "quantity" in my code:

    a) private int quantity = 1;
    b) ExitLong(Convert.ToInt32(quantity), @"ExitLong", @"EntryLong");
    c) ExitShort(Convert.ToInt32(quantity), @"ExitShort", @"EntryShort");

    Was this the next step and its right so?
    What is the next one?


    Best regards,
    Rainbowtrader
    Attached Files
    Last edited by Rainbowtrader; 08-30-2023, 02:17 AM.

    Comment


      #17
      With implementing the OnExecutionUpdate code block I got this problems:

      Click image for larger version

Name:	error.png
Views:	63
Size:	66.1 KB
ID:	1266710

      Comment


        #18
        Hello Rainbowtrader,

        Are there compile errors?

        If so, what are the compile errors?


        With this code you have a screenshot of checking position, if you want to run logic when the position changes, this should be in OnPositionUpdate().


        In OnExecutionUpdate() when the execution occurs (meaning a fill has occurred), you can check the name and time of the execution.
        Print(execution.Name + " " + execution.Time);
        Print(execution.ToString());


        "But the fix exit times has no effect: if bool is on or off makes no difference."

        If the bool is false, these orders are still being submitted?

        You are using prints to show that this action block from the if condition is being executed as the condition is evaluating as true?

        Below is a link to a forum post on using Print() to understand behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Hi Chelsea,

          I am searching since a while for a SIMPLE example script OR the correct code for MY script for 2 or 3 or 4 time stops. So that if an order hit its, the order will quit. No more.

          This theme is running now in so different dead ends or in a kind of occupational therapy, for that I really have no time. I dont sell code or scripts - I am using its for myself. I am searching for a simple solution.

          Can you giving me an example script with 2 different time stops? I cant believe, that this never asked a trader before. So an example should be exits, or?

          Thank you for your help, but if you dont run my example script, this will takes weeks over weeks or months over months. Do you understand me?

          Best regards,
          Rainbowtrader

          Comment


            #20
            Hello Rainbowtrader,

            There are not any examples I am aware of that are only allowing exit orders to be submitted between a time range. The examples I am aware of use logic in OnBarUpdate() to prevent the entry order outside of the time range.

            Below are links to examples of using time conditions.

            Hello, I am building a strategy to use with the MACD indicator and am trying to have it turn on at specific times to place an order. For example, turn on the strategy from 1:30-2:00am and then reactivate at 3:00-3:30am etc. for multiple times throughout the day. I have built 5 separate strategies for the times I want, however

            I'm experiencing a problem when I attempt to use a time value as a user input parameter in my strategy, while testing in optimizer. My objective is to be able to easily change the strategy trading hours from within the optimizer user input parameters. I've programmed time values as user inputs in Builder. However, when I run



            Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one on one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.

            That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.


            That said, adding prints and getting output will identify why or why not the condition in your updated code has evaluated as true as false.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            52 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            70 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            48 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X