Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom event in button region and Swing()

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

    Custom event in button region and Swing()

    Hello,

    I have the following code outside of OnBarUpdate(), this is in OnMyButtonClick(). Because of this I believe I need to use TriggerCustomEvent(). I've used this in the past in this section with success but this time I have multiple data series and while debugging it looks like I need to change this code to point to the primary data series.

    Code:
    TriggerCustomEvent( o =>
    {
         if(Swing(swingStrength).SwingHighBar(0, 1, CurrentBar) > 0 && Swing(swingStrength).SwingLowBar(0, 1, CurrentBar) > 0)
         {
              swingHiPrice = Highs[0][Swing(swingStrength).SwingHighBar(0, 1, CurrentBar)];
              barsSinceSwingHi = Swing[B](Highs[0][0],[/B] swingStrength).SwingHighBar(0, 1, CurrentBar);
         }
    |
    I'm also trying to use :

    Code:
    MAX(High, barsSinceSwingHi)[0] <= swingHiPrice
    Does anyone know how I can make this change to the MAX() function and also the barsSinceSwingHi use of Swing()?

    I was thinking that I could just pass Highs[0][0] into the bars since function but that doesn't seem to work.


    #2
    Hi Walter, thanks for writing in.

    The MAX and Swing will take a Series object. Passing the first Highs array like this:

    Code:
    swingHiPrice = Highs[0][Swing([B]Highs[0][/B], swingStrength).SwingHighBar(0, 1, CurrentBar)];
    barsSinceSwingHi = Swing[B]([/B][B]Highs[0][/B][B],[/B] swingStrength).SwingHighBar(0, 1, CurrentBar);
    ]

    For MAX:

    Code:
    MAX(Highs[0], barsSinceSwingHi)[0] <= swingHiPrice
    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you so much that is exactly what I was looking for!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      86 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      151 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      53 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      61 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X