Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Personalizing SampleAtmStrategy

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

    Personalizing SampleAtmStrategy

    Hi everyone

    With a new powerful PC and a tested strategy, I’m very close to being in a position to place my first automated trades using ATMs.

    The biggest hurdle for me (and looking through the Forum, this has obviously been the case for many others) is to adapt the SampleAtmStrategy for my own purposes. The coding is complex and there seems to be room for a lot of mistakes to creep in.

    I’ll paste below some of the code from SampleAtmStrategy. The lines in blue are the ones I have queries about.

    1)

    Original:
    if (orderId.Length == 0
    && atmStrategyId.Length == 0
    && Close[0] > Open[0])

    Am I right in replacing the above line in blue with, for example (and this isn't a working strategy in any way!) something like:

    if (
    orderId.Length == 0
    && atmStrategyId.Length == 0
    && MACD(12, 26, 9).Avg[0] > 0
    && MACD(12, 26, 9).Avg[1] <= 0
    && Rising(EMA(16))

    )

    2)

    AtmStrategyCreate(Cbi.OrderAction.Buy,
    OrderType.Market, 0, 0, TimeInForce.Day, orderId,
    "AtmStrategyTemplate", atmStrategyId);

    Am I right in thinking this enters a Buy order at Market and that the “0,0” means this is neither a stop nor limit a order?

    3)

    I don't fully understand the function of the following if statement and action:

    if (atmStrategyId.Length > 0)
    {
    if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
    AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);

    If the stops are controlled by the ATMs uniquely, what is the function these lines and why invoke AtmStrategyChangeStopTarget?

    Thanks very much in advance.

    #2
    Hello arbuthnot,

    Thank you for your post.

    1) Yes, you can replace the Close > Open check with your own logic here.

    2) This is telling the entry order to be a buy order for a market type. The 0,0 are for Stop and Limit prices and are only relevant with placing Limit, Stop, or StopLimit orders.

    3) This is checking that the ID exists with more than 0 length. It then checks that it is not flat. This is if you wanted to change the StopTarget your own method or where checking for certain market conditions and needed to change it.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks very much for your reply, Cal.

      1) Yes, you can replace the Close > Open check with your own logic here.
      This is totally clear. Thanks.

      2) This is telling the entry order to be a buy order for a market type. The 0,0 are for Stop and Limit prices and are only relevant with placing Limit, Stop, or StopLimit orders.
      Again, this is totally clear. Thanks.
      3) This is checking that the ID exists with more than 0 length. It then checks that it is not flat. This is if you wanted to change the StopTarget your own method or where checking for certain market conditions and needed to change it.
      a) Does this effect a change within the ATM or does it change a stop outside of the ATM? If so, how?

      b) Can the part of code starting with:

      Code:
      if (atmStrategyId.Length > 0)
      be left out altogether (as the rest of it only controls some printing)?

      Much obliged in advance if you could assist me further with these points.

      Comment


        #4
        arbuthnot,

        A) Does this effect a change within the ATM or does it change a stop outside of the ATM? If so, how? This will affect the ATM strategy with the ID that is being checked.

        B) This decision is left up to you, however, this check is essentially checking the string if its null or not.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          B) This decision is left up to you, however, this check is essentially checking the string if its null or not.
          Thanks but what would be the consequences of this part being left out?

          (I have a lot of experience now coding indicators and strategies but SampleAtmStrategy is distinctly new territory for me so please forgive me if there are points which aren't immediately obvious to me.)

          Much obliged.

          Comment


            #6
            arbuthnot,

            It is a check that we have indeed submitted an order with a viable ID. If there was no ID and we requested some information on the ID, it would return an error. This check is to prevent that error message.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by arbuthnot View Post
              Thanks but what would be the consequences of this part being left out?

              (I have a lot of experience now coding indicators and strategies but SampleAtmStrategy is distinctly new territory for me so please forgive me if there are points which aren't immediately obvious to me.)

              Much obliged.
              Code:
              ... AtmStrategy[COLOR="Navy"]ChangeStopTarget([/COLOR]0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
              It is changing the Stop. If you are not going to change the Stop, that statement block is irrelevant. It is only there as an example of a safe way to adjust anything. The Stop was just the particular example used.

              Comment


                #8
                Thanks very much, Cal and Koganam, for your help with this last point.

                I think I now fully grasp all the methods involved in this Strategy and now hope to be able to adapt it to my own needs exactly.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by carnitron, Today, 08:42 PM
                0 responses
                5 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Today, 07:51 PM
                0 responses
                7 views
                0 likes
                Last Post strategist007  
                Started by StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,974 views
                3 likes
                Last Post jhudas88  
                Started by rbeckmann05, Today, 06:48 PM
                0 responses
                8 views
                0 likes
                Last Post rbeckmann05  
                Started by rhyminkevin, Today, 04:58 PM
                4 responses
                58 views
                0 likes
                Last Post dp8282
                by dp8282
                 
                Working...
                X