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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X