Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ask: Unmanagedorder with 2 TPs & MyButtonclick`s

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

    Ask: Unmanagedorder with 2 TPs & MyButtonclick`s

    Hello again,

    i copy and paste anything i need for my little "Helper" and now after 1 week work without success, i need a little help to understand two things:

    1. I want with "Buy-Button-Click" that i entry with 2 Contracts. Every Contract have a own Profittarget & Stoploss. My problem when i re-write the code is, the system delete all PF & SL at beginning or when it hit one of them, then the system delete all PF & SL and 1 Contract have nothing.

    2. The Helper have a Button "Next LONG OFF". With Buttonclick i change Colour and set a boolvariable to true... Can i use a "Mouse Simulation" in OnBarUpdate? What i want is, when the Strategie enter Long then i want the "Next LONG On" to reset to there defaults.

    When i understand the concept, then i can complete my first Strategie

    Thats my "Helper"



    And thats my Code (i use the unmanagedTemplate)

    Attached Files
    Last edited by Dirales; 05-27-2023, 02:53 AM.

    #2
    Hello Dirales,

    Thanks for your post.

    Please send me the exact steps and settings you use to reproduce the behavior so I may look into this matter further.

    I will use the steps and settings you share to try and reproduce the behavior on my end using the script you shared.

    Thanks in advance; I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello Brandon,

      the full code i use is the ZipFile "DiraHelper" in Post Home

      In Z574 - Z582 i change the Button_LongME like this

      Code:
      protected void MyButtonClick(object sender, RoutedEventArgs e)
              {
      
                  if (sender == myButton_LongME)
                  {
                      if (Button_LongME == false)
                          {
                              myButton_LongME.Content = "Next LONG ON";    Button_LongME = true; myButton_LongME.Background = Brushes.Orange; return;
                          }
                      if (Button_LongME == true)
                      {
                              myButton_LongME.Content = "Next LONG OFF";    Button_LongME = false; myButton_LongME.Background = Brushes.White; return;
                  }} //if (sender == myButton_LongME)  ​
      and then OnBarUpdate Z190 - Z201
      Code:
      if(Position.MarketPosition == MarketPosition.Flat)
                          {
                              if (Button_LongME == true)
                              {
                                  if ((Close[2] < Open[2]) && (Close[1] > Open[1]))
                                  {
                                      SubmitOrderUnmanaged(1, OrderAction.Buy, OrderType.Market, 1, 0, Close[0] - (TrailStopDistanceMAX * TickSize),  oco, "Long1");
                                      CurrentTriggerPrice = (Close[0] + (TrailFrequenz * TickSize)) ;
      //                                CurrentStopPrice = (Close[0] - (TrailStopDistanceMAX * TickSize)) ;
      [COLOR=#1abc9c] myButton_LongME.Background = Brushes.White; myButton_LongME.Content = "Next LONG OFF"; //NOT Working[/COLOR]
                                  }
                              }​
      myButton_LongME.Background = Brushes.White; myButton_LongME.Content = "Next LONG OFF"; //NOT Working
      What can i do, to reset the Button to their defaults?

      Comment


        #4
        Hello Dirales,

        Thanks for your note.

        We do not have a reference sample available demonstrating this specifically. A dispatcher would need to be used and you would set the button color.

        Please view the EMAToggleExample script shared by NinjaTrader_Kate on this forum thread for an example of changing button colors: https://forum.ninjatrader.com/forum/...11#post1166611

        And, see the Using A Dispatcher section of this help guide page: https://ninjatrader.com/support/help...sub=dispatcher
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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