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

EnterLongLimit()

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

    EnterLongLimit()

    The EnterLongLimit() order method allows for a string signalName to be set.

    I'm guessing the answer will be no but thought I'd ask anyway: is there a way to set (or modify) the EnterLongLimit() string name after the actual order has been executed?

    #2
    Hello newuser,

    Thank you for your post.

    There would not be a means to change the signalName after execution.

    What are you attempting to achieve with this idea?

    Comment


      #3
      Hi Patrick,

      Thanks for the reply. I had an idea to get the Order ID from OnExecution and use that value in the signal name (for the entry, stop and profit) as a way of tracking trades.

      I wanted to do that because I have a strategy where the same condition set generates multiple open trades and I was having trouble implementing a breakeven strategy using BarsSinceEntry....but I since came up with another solution.

      I've actually had so much grief with this that I thought I'd post the solution just in case other users are having the same issue. I kind of thought it would be a common thing but I didn't find a similar issue anywhere and so I had to piece together a solution from several different sources.

      So I started by using an integer user variable that incremented if my conditions were met and then passed that count into the signal name like so:

      Code:
      private int count=0;
      
      if (//conditions)
      { count++;
        EnterLongLimit("Long"+count); }
      
      if (BarsSinceEntry()==1)
      { //execute code }
      The problem with this approach is the count iterates every time the conditions are met, so if the conditions are met on 2 consecutive bars then at BarsSinceEntry() == 1 the count value will be out of sync by 1 and will no longer reference the initial trade from the first bar. I fixed this with a user defined boolean variable:

      Code:
      if (//conditions)
      { count++;
        EnterLongLimit("Long"+count);
        trigger = true; }
      else { trigger = false }
      
      if (trigger = true)
      {  if (BarsSinceEntry("Long"+(count-1)) == 1)
         { // execute code }
      }
      
      else if (trigger = false)
      {  if (BarsSinceEntry("Long"+count) == 1)
         { // execute code }
      }
      Now the code syncs the signal names perfectly. If the conditions were met on the second bar it deducts one from the integer value used to reference the signal name (and if not then it doesn't).

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      8 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      6 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X