Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Problem with TriggerCustomEvent

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

    Problem with TriggerCustomEvent

    Hi,

    I'm using TriggerCustomEvent but it only seems to work twice

    This is the basic code
    Code:
    [FONT=Courier New][SIZE=2]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] myMouseEvents([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] sender, MouseEventArgs e)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//TriggerCustomEvent(new CustomEvent(myCustomEvent),e );[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]TriggerCustomEvent([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] CustomEvent(myCustomEvent), BarsInProgress, e);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"click"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]); [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] myCustomEvent([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] state)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"click2"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]); [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
    [/SIZE][/FONT]
    Then when I click on the chart, the output looks like this
    Code:
    click2
    click
    click2
    click
    click
    click
    click
    click
    So myMouseEvents is called every time I click on the chart, but myCustomEvent is only called the first two times, then gives up.

    Does anyone know why this would happen?

    Thanks

    #2
    Hi bubblegum,

    This is more C# related so will fall outside our scope of support. Hopefully experienced community members can offer their input here. If you've not looked here already, we have a sample using custom events that may be useful for you:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks. I managed to fix it.

      I was using
      public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
      to plot the graphics. So I replaced this with
      private void myPlot()

      and put a call to this method in my event and it all seems to work fine now.

      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by truepenny, Today, 03:45 AM
      4 responses
      20 views
      0 likes
      Last Post truepenny  
      Started by nightstalker, 05-04-2024, 02:05 PM
      4 responses
      45 views
      1 like
      Last Post Leeroy_Jenkins  
      Started by Drone360x, Today, 10:27 AM
      0 responses
      3 views
      0 likes
      Last Post Drone360x  
      Started by NUVERSA, Today, 10:08 AM
      2 responses
      12 views
      0 likes
      Last Post NUVERSA
      by NUVERSA
       
      Started by truepenny, Today, 03:59 AM
      5 responses
      22 views
      0 likes
      Last Post truepenny  
      Working...
      X