Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading stops

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

    Trading stops

    I am brand new at automated trading with Scripts.
    I have a script that executes trades, however after the first order it stops executing trades... what am I missing?

    #2
    Hello,
    I am not sure.

    You can try debugging it:


    Or post the OnBarUpdate() block of your code and we can give you pointers.
    Also, compare your code to the sample strategies to see what the issue may be.
    DenNinjaTrader Customer Service

    Comment


      #3
      Here's my code...

      Code:
       
      if (Input[0] > MACDBB(12, 26, 9).Avg[0] && Above == false)
      {
      Retrace = false;
      Above = true;
      Below = false;
      Print("Cross Above");
      }
      
      // Condition set 2
      if (Input[0] < MACDBB(12, 26, 9).Avg[0] && Below == false)
      {
      Retrace = false;
      Above = false;
      Below = true;
      Print("Cross Below");
      }
      if (FirstTickOfBar && Above == true && LongOrder == false)
      {
      PriorBarRetrace = Round2Tick(((High[1]-Low[1])*.382)+ Low[1])-TickSize;
      Print("Retrace target = " + PriorBarRetrace);
      }
      if (FirstTickOfBar && Below == true && ShortOrder == false)
      {
      PriorBarRetrace = Round2Tick(((High[1]-Low[1])*.618)+ Low[1])+TickSize;
      Print("Retrace target = " + PriorBarRetrace);
      }
      if (Input[0] <= PriorBarRetrace && Above == true && LongOrder == false)
      {
      Retrace = true;
      LongOrder = true;
      ShortOrder = false;
      ExitShort("MACDfollowShort");
      EnterLong("MACDfollowLong");
      Print("ExitShort, EnterLong");
      }
      if (Input[0] >= PriorBarRetrace && Below == true && ShortOrder == false)
      {
      Retrace = true;
      ExitLong("MACDfollowLong");
      LongOrder = false;
      ShortOrder = true;
      EnterShort("MACDfollowShort");
      Print("ExitLong, EnterShort");
      }

      Comment


        #4
        Hello,

        The first thing I see is that this looks like an "always in" strategy, meaing you have an order in the market at all times. When doing this, don't use Exits, just place an order in the opposite direction and it will cancel the order you just had. See the SamleMACrossOver. That should eliminate some of your flags and simplify the code. Try than and see if you can sort out the issue.
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Buttony, 01-18-2025, 12:10 PM
        12 responses
        58 views
        0 likes
        Last Post rockmanx00  
        Started by lorien, 01-15-2025, 12:10 PM
        7 responses
        77 views
        2 likes
        Last Post qewcool
        by qewcool
         
        Started by slade3789, 01-16-2025, 01:12 AM
        2 responses
        23 views
        0 likes
        Last Post slade3789  
        Started by tardi44, 09-07-2023, 07:20 AM
        2 responses
        152 views
        1 like
        Last Post ingresoscontalento  
        Started by Tagliareni, 01-18-2025, 10:04 AM
        2 responses
        27 views
        0 likes
        Last Post Tagliareni  
        Working...
        X