Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bullish to Bearish

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

    Bullish to Bearish

    Hi all,

    I'm fairly confident in how I entered everything into Strategy Builder, but looking at the strategy analyzer it does not appear to be correct.

    As a minimum working example, say I want to enter short after a bullish candle and current price falls below open of previous bullish candle. I would assume the proper C# would be:

    Code:
    if ((Close[1] > Open[1]) && (CrossBelow(Close, Open, 1)))
    However, when looking at the strategy analyzer chart it appears as though it is entering after bearish candles? Screen shots attached. I've also attached an example of desired entry points circled in blue.

    Any guidance would be greatly appreciated!

    Click image for larger version

Name:	Screenshot 2022-06-07 233625.png
Views:	281
Size:	30.4 KB
ID:	1204310
    Click image for larger version

Name:	Screenshot 2022-06-07 233654.png
Views:	218
Size:	11.1 KB
ID:	1204311
    Click image for larger version

Name:	Screenshot 2022-06-08 000523.png
Views:	231
Size:	14.5 KB
ID:	1204312

    #2
    Hello gravityflyer,

    The entries would be based on the condition you made so if they were submitted that would mean the price values at that time allowed the condition to enter.

    You could use a Print at the time of the entry to see what the values were at that time to better understand why the condition was true. Alternatively you would have to take a look at the bar values at the time of the circled areas and see how those values work with the condition you made.

    Comment


      #3
      I tried a few more tweaks but still getting the same strange result, i.e. it is entering when crossing the close of a previous bullish candle. Almost the exact inverse of my desired strategy!

      Click image for larger version

Name:	Screenshot 2022-06-08 125751.png
Views:	230
Size:	36.7 KB
ID:	1204408

      It's driving me crazy. Lol. Any additional suggestions would be greatly appreciated!

      Comment


        #4
        Hello gravityflyer,

        Really you need to use a print here to better understand why that condition was true. Prints can be accessed from the actions -> Misc -> Print.

        From the chart I can't tell what values were seen for the two parts of your condition. You are comparing the previous bars close vs its open and also checking if the close crossed the open. Without knowing what prices the open and close were for each of those conditions we couldn't really say why the condition as true. I can say that It was true because the prices allowed for it so that may not be the correct condition for the use case.

        The cross method with 1 period works by comparing the last and current bars value to check if a crossing happened, to find out why that was true you would need to print both the current and last bars values.

        You can also use a chart with the data box to view each bars values however you would need to write those values down so you can apply them to your condition to see why it was true.


        Comment


          #5
          Hi Jesse,

          First off, thank you very much for taking the time to help solve my issue -- greatly appreciated!

          As you suggested, I did a print() of open/close values and confirmed that my coding and I agree that my conditions are not matching my desired result. See attached.

          Click image for larger version

Name:	Screenshot 2022-06-09 225400.png
Views:	225
Size:	79.0 KB
ID:	1204659
          Click image for larger version

Name:	Screenshot 2022-06-09 225238.png
Views:	199
Size:	7.6 KB
ID:	1204660

          I suppose I should take a step back from this minimal working example and ask what would be the appropriate conditions for my desired short entry point? I assumed that
          Code:
          Close[1]>Open[1]
          would determine whether the prior bar was bullish (i.e. close > open), and subsequently
          Code:
          && CrossBelow(Close, Open,1)
          would serve as the trigger of current bar price crossing below the open of the previous bullish bar. Clearly this is incorrect?

          Comment


            #6
            By way of follow-up, I think I narrowed my problem down to defining whether the previous candle is bullish (defined as close>open). I did a simple code to enter after a bullish bar:

            Code:
             protected override void OnBarUpdate()
            {
            if (BarsInProgress != 0)
            return;
            
            if (CurrentBars[0] < 1)
            return;
            
            // Set 1
            if (Close[1] > Open[1])
            {
            EnterShort(Convert.ToInt32(DefaultQuantity), "");
            }
            
            }
            Unfortunately the strategy analyzer reveals some inconsistencies, i.e. sometimes it enters after a bullish candle, but other times it entered after a bearish candle!

            Click image for larger version

Name:	Screenshot 2022-06-10 122338.png
Views:	252
Size:	63.3 KB
ID:	1204734

            Any insight would be greatly appreciated!

            Comment


              #7
              Hello gravityflyer,

              For the incorrect entries you would need to identify what part of the price condition at that time allowed for it to be true. In a backtest the strategy is evaluated OnBarClose so if the price condition happens but then the next bar is a large drop like pictured it would end up entering within that bars values based on the historical fill engine. You may want to try playing through playback data to see if the condition executes in a more correct way in realtime data. You would otherwise need to determine what the values are in the highlighted yellow area and then see if there is some factor that you can put in additional conditions for to avoid that situation.



              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