Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated Strategy Help/Limit order entry to initial conditions being met

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

    Automated Strategy Help/Limit order entry to initial conditions being met

    I need help with how to limit my automated strategy to only when the initial conditions develop. As of now I have my strategy working but once I hit my profit target and if the conditions are still valid then it takes another trade. Hopefully that makes sense. My understanding of coding is basic to say the least but got thru it with a Ninjatrader help video and so far so good but this is the only element that is messing up my strategy when backtesting it. Thanks for any help.

    Jason

    #2
    Originally posted by jwisniewski View Post
    I need help with how to limit my automated strategy to only when the initial conditions develop. As of now I have my strategy working but once I hit my profit target and if the conditions are still valid then it takes another trade. Hopefully that makes sense. My understanding of coding is basic to say the least but got thru it with a Ninjatrader help video and so far so good but this is the only element that is messing up my strategy when backtesting it. Thanks for any help.

    Jason
    This should help you here:

    Comment


      #3
      Correct me if I'm wrong but that link seems to be a date/time correction. I think I am looking for something different...again I am new to this much less coding so I will try and elaborate. After my trade has been exited whether it was a winning or losing trade, I don't want the automated strategy to reinitiate until after the conditions have been re-met. Right now my automated strategy is entering another trade after the prior trade closes if the conditions are still being met and I don't want that to happen. It seems like it would by some type of Boolean logic but do I have to write it myself or can it be found in the strategy wizard etc.

      thanks again

      Comment


        #4
        Down at NT Austin post. 1 trade per day.
        You need logic to reset that for the next day.

        Comment


          #5
          easiest way would be to use bool parameter

          you can then just set this bool to true on your initial setup and to false once u enter a trade for example. if you then let him just enter new trades as long as this bool is true, then he would have to wait for another initial setup (bc this would be the next chance of the bool being set to true)

          Comment


            #6
            Hello jwisniewski,

            Thank you for writing in. This is possible in the Strategy Wizard using 2 booleans and 3 condition sets.
            In your first condition set you need to check if the conditions to enter the order are true and if the second boolean is false, then set both booleans to true.
            Code example:
            Code:
            if(myConditions == true && myBoolean2 == false)
            {
            myBoolean = true;
            myBoolean2 = true;
            }
            In your second condition set you need to check if the conditions to enter the order are false and if the second boolean is true, then set the second boolean to false.
            Code example:
            Code:
            if(myConditions == false && myBoolean2 == true)
            {
            myBoolean2 = false;
            }
            In your third condition set you need to check if the first boolean is true and if so, submit the order and set the first boolean to false.
            Code Example:
            Code:
            if(myBoolean == true)
            {
            EnterLong();
            myBoolean = false;
            }
            NOTE: Both booleans need to have a default value of false.

            So basically the flow would be like this:

            1) entry conditions are met
            2) An order is placed
            3) At this point myBoolean2 is true and myBoolean is false.

            If the entry condition continues being true for any number of bars, no more orders will be submitted until the condition has been false at least once because myBoolean cannot be set back to true until myBoolean2 is set to false. And myBoolean2 cannot be set to false until the entry condition is no longer true.

            Please let me know if you have any questions or if I may be of further assistance.
            Michael M.NinjaTrader Quality Assurance

            Comment


              #7
              EDIT: oh, you already got an example. but i already typed it so whatever, pick the one that is easier understandable for you

              To include an example.

              lets say ur intial setup would be the initial candle that the RSI(12) goes over 90. If you now use
              if (RSI(12)[0]>90)
              EnterLong;

              to enter the trade, then he would ofc still enter later if that condition is still met

              the way u implement a bool here would be

              if (RSI(12)[0]>90)
              condition=true;

              you now have to find the condition that describes every other situation than ur intial one and set the bool to false there. in this case it would be RSI being under 90 and RSI being over 90 while being over 90 the candle before as well. so

              if((RSI(12)[0]<=90) || (RSI(12)[0]>90 && RSI(12)[1]>90))
              condition=false;

              then you could just use the condition bool to enter the trade using

              if (condition)
              EnterLong;
              Last edited by BigRo; 11-08-2015, 05:59 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Max238, Today, 01:28 AM
              1 response
              22 views
              0 likes
              Last Post CactusMan  
              Started by giulyko00, Yesterday, 12:03 PM
              2 responses
              10 views
              0 likes
              Last Post giulyko00  
              Started by r68cervera, Today, 05:29 AM
              0 responses
              4 views
              0 likes
              Last Post r68cervera  
              Started by geddyisodin, Today, 05:20 AM
              0 responses
              7 views
              0 likes
              Last Post geddyisodin  
              Started by JonesJoker, 04-22-2024, 12:23 PM
              6 responses
              38 views
              0 likes
              Last Post JonesJoker  
              Working...
              X