Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit conditions don't trigger as they are supposed to

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

    Exit conditions don't trigger as they are supposed to

    the exit condition of my strategy never even triggers though according to the chart they should have triggered.

    when the price crosses below ema the exit condition should have triggered and exited the long position but it doesn't even though it clearly shows that on the chart. i included the strategy

    i used AMD 2 mins or 4 mins any time period doesn't work
    Attached Files
    Last edited by Mo98alda; 04-07-2022, 04:18 AM.

    #2
    Hi Mo98alda, thanks for writing in. The Cross methods need the value to be over the comparing value on the previous bar and then under it on the current bar for the cross to trigger. So the problem is that the Ask values are different on each bar and either above or below the EMA price, even if you do the opposite where you compare the EMA series to the Ask value e.g. CrossAbove(EMA1, GetCurrentAsk, 1) the EMA price needs to be under the value of GetCurrentAsk on the previous bar and below the same value of GetCurrentAsk. In most cases, GetCurrentAsk will already be above or below on the next bar. The solution is to add an Ask series of the instrument you are running the strategy on so it can look back at previous Ask values. Unfortunately, most data providers will not give historical Ask prices so you will need to test it out either in Real Time only or in the Playback connection.

    Kind regards,
    -ChrisL
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi Mo98alda, thanks for writing in. The Cross methods need the value to be over the comparing value on the previous bar and then under it on the current bar for the cross to trigger. So the problem is that the Ask values are different on each bar and either above or below the EMA price, even if you do the opposite where you compare the EMA series to the Ask value e.g. CrossAbove(EMA1, GetCurrentAsk, 1) the EMA price needs to be under the value of GetCurrentAsk on the previous bar and below the same value of GetCurrentAsk. In most cases, GetCurrentAsk will already be above or below on the next bar. The solution is to add an Ask series of the instrument you are running the strategy on so it can look back at previous Ask values. Unfortunately, most data providers will not give historical Ask prices so you will need to test it out either in Real Time only or in the Playback connection.

      Kind regards,
      -ChrisL
      thanks for the reply i have a market data subscription to IB and i have downloaded and used the historical ask minute data from IB the problem doesn't change

      Comment


        #4
        Hi, thanks for the follow up. I'm assuming you are replaying AMD data. To replay any equity with the "historical" option in the replay controller, you will need historical tick data but IB does not provide this. You will need a Kinetick or IQ feed connection to supplement the IB connection. To test the strategy now, try it out on futures data, which can be downloaded from Tools>Historical Data>Load.

        Here is the page that covers the data supplied by each supported connection:


        Kind regards.

        Comment


          #5
          Upon reflection, I realized Kinetick will not give us historical Bid/Ask tick data either, only last. There is a special way we can identify a tick as a bid or ask tick through a 1 tick last series. I uploaded an example for you. IB will let you download historical minute data, so using a 1 Minute Ask series should work in the backtest.
          Attached Files

          Comment


            #6
            Originally posted by NinjaTrader_ChrisL View Post
            Upon reflection, I realized Kinetick will not give us historical Bid/Ask tick data either, only last. There is a special way we can identify a tick as a bid or ask tick through a 1 tick last series. I uploaded an example for you. IB will let you download historical minute data, so using a 1 Minute Ask series should work in the backtest.
            hi as i said before i have downloaded all historical minute data including ASK, BID, and LAST. changing the time frame i use in the backtest to the 1 minute timeframe or trying to change to last or ask or bid still doesn't fix this problem. and I'm not proficient in coding so can you just show me the strategy working through the strategy builder.

            Comment


              #7
              Hi, the sample I posted earlier will work in the builder. Paste the .cs file into Documents\NinjaTrader 8\bin\Custom\Strategies and then press Compile in any strategy builder window.

              Kind regards,
              -ChrisL

              Comment


                #8
                Originally posted by NinjaTrader_ChrisL View Post
                Hi, the sample I posted earlier will work in the builder. Paste the .cs file into Documents\NinjaTrader 8\bin\Custom\Strategies and then press Compile in any strategy builder window.

                Kind regards,
                -ChrisL
                is this possible to replicate through the wizard as i said before i don't know how to code and so i still don't know how to fix my own strategy through the strategy wizard

                Comment


                  #9
                  Hi Mo98alda, you have to replace the file because all the strategy builder does is generate these .cs files in the strategies folder.

                  Kind regards,
                  -ChrisL

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChrisL View Post
                    Hi Mo98alda, you have to replace the file because all the strategy builder does is generate these .cs files in the strategies folder.

                    Kind regards,
                    -ChrisL
                    okay i copied the file into the strategies folder but i couldn't open it up in either the strategy builder or the analyzer, I found It in the ninjascript editor and compiled it there but that accomplished nothing as my strategy doesn't work at all and neither can i open the file in either the strategy builder or the analyzer and my strategy still doesn't work.

                    Can you just give me straight forward and clear instructions that lead to my strategy working because nothing has changed at this point and nothing you said previously made it work.

                    Comment


                      #11
                      Hi I apologize, I had the unlocked version uploaded. I uploaded a .zip this time that will work in the builder. Download this then go to Tools>Import to add it say Yes to replace the file. I added a 1 minute Ask series and used that series in the cross condition in set 2.

                      Kind regards,
                      -ChrisL
                      Attached Files

                      Comment


                        #12
                        Originally posted by NinjaTrader_ChrisL View Post
                        Hi I apologize, I had the unlocked version uploaded. I uploaded a .zip this time that will work in the builder. Download this then go to Tools>Import to add it say Yes to replace the file. I added a 1 minute Ask series and used that series in the cross condition in set 2.

                        Kind regards,
                        -ChrisL
                        Thank you for all the help chris

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by NullPointStrategies, Yesterday, 05:17 AM
                        0 responses
                        64 views
                        0 likes
                        Last Post NullPointStrategies  
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        139 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        75 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        45 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        50 views
                        0 likes
                        Last Post TheRealMorford  
                        Working...
                        X