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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X