Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Short only enters on close of green candle?

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

    Short only enters on close of green candle?

    Hi folks. Attempting to create a condition on Renko charts in Strategy Builder where a short is entered when it is below the yellow EMA (21). However, as per the graphic, it is only entering a short whenever the previous candle closes green. How do I make it so that it only enters the short when the previous candle closed red?Click image for larger version

Name:	image.png
Views:	173
Size:	38.4 KB
ID:	1304430

    You can see how it enters long on only the close of green candles here, so I thought it would have the reverse logic for shorts. Any help is appreciated!
    Click image for larger version

Name:	image.png
Views:	207
Size:	43.9 KB
ID:	1304431

    #2
    Hello amichalska,

    Thank you for your post!

    If the close is less than the open, then it would be a red bar. So to only enter when the previous bar is red, you could do something like below:

    Code:
    if (Close[1] < Open[1])
    EnterShort();
    Please let us know if you need further assistance.

    Comment


      #3
      Gaby, thank you kindly for responding.
      I'm only using the Strategy Builder wizard, and I'm not sure what to select in the Conditions and Actions panel that will equal your code. Could you please assist? I attempted this below but it doesn't seem to be correct.
      Click image for larger version

Name:	image.png
Views:	150
Size:	21.0 KB
ID:	1304446

      Comment


        #4
        Hello,

        That screenshot is correct.

        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.

        In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.

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


        Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

        Let me know if you need any assistance creating a print or enabling TraceOrders.

        Save the output from the output window to a text file and provide this with your reply.

        I'll be happy to assist with analyzing the output.​

        Comment


          #5
          NinjaScript Output 2024-05-22 8_55 AM.txt Hi Gaby, thanks for the reply.
          I'm posting a screenshot of my Sets as well as an example on chart for May 20th, where the short condition should have triggered (yellow line is 19 EMA, blue is 7 EMA). I'm noticing that the short condition is not triggering at all. I'm also including the print text file per your request and I hope that I followed the instructions on Chelsea's video correctly for you. I look forward to your reply!
          Screenshot of May 20, 2024 on ES:

          Set 1:
          Click image for larger version

Name:	image.png
Views:	159
Size:	9.2 KB
ID:	1304530
          Set 2 where Default input[0] < Open [0] is the screenshot I posted above with Price(close) is less than Price(open), however I want this to trigger at the close of every candle so I left "bars ago" to 0:

          Set 3 includes the print information done to the best of my ability:
          ​​​

          Comment


            #6
            Hello,

            I'm not able to open the text file you've attached here for some reason. Can you try re-adding the attachment please?

            I also only see 1 screenshot for Set 1.

            Comment


              #7
              Hi Gaby, trying again, does this work?
              Attached Files

              Comment


                #8
                Hello amichalska,

                Thank you, I was able to download the file now.

                Your prints should include info for every single condition, not just the EMA condition. Your sets have several conditions that are taken into consideration when the script is deciding to place the order or not; such as the current market position, a time filter, and comparing the Open to the Close.

                In order to determine why the strategy is not placing orders when expected, we need to know the values for all these conditions.

                The prints 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 helpful to include labels and operators in the print to understand what is being compared in the condition sets.

                If you need assistance with creating a print please let me know.

                Comment


                  #9
                  Hi Gaby, thanks for your reply and I understand what you're saying.
                  I'm going to be honest, I have no idea how to include the other conditions in the print, unfortunately. I'm pretty brand new to Ninjascript.
                  If you could assist me with this, I'm happy to receive your help.
                  Otherwise, if you think there might be another way I can assist with this, please let me know, perhaps stripping some of the conditions might help but at the same time, they might not provide the full picture if they are added back. Please advise, thank you so much.

                  Comment


                    #10
                    Hello amichalska,

                    Thank you for your response.

                    Please see the attached script which has a sample print for your EnterLong() set. You will need to create a similar set for your EnterShort() set, and any other set you have in your script.

                    If you have any questions about the example please let me know.

                    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.
                    Attached Files

                    Comment


                      #11
                      Gaby, I figured it out. It's embarrassing but I just realized I had two conflicting conditions in my short condition set. It had both Default input[0] > Open[0] at the very top, AND Default input[0] < Open[0] that was added (on the bottom) based on your suggestions in this thread. The script is working exactly as intended now after removing the top condition. No wonder it wasn't taking any trades at all.
                      Thanks again for everything, Gaby, sorry to have wasted your time. Appreciate your fast responses.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Today, 05:17 AM
                      0 responses
                      29 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      124 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      64 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      41 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      46 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X