Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where to start if I want to create a strategy on a trading set-up?

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

    Hi Ryan

    I'm thrilled to report that I succeeded in adding some ATM codes to my strategy based on the NJ ATM Strategy Sample LOL! It's very effective for intrabar SL/PT adjustment while the other options like Price Modification/Trail have to wait for a bar's completion.

    Need to pick your brains please. I would like to learn how to add some codes so that I will get a phone/msn/text/email alert (an alert of any kind) when a strategy triggers a trade + ideally if the order (incl pending PT/SL one) is filled. Sometimes I will not be around the computer + I may run a strategy after midnight. Adding an alert code will save me staying up all night to monitor a strategy. Awaiting your kind guidance. Thank you.
    Last edited by belecona; 09-09-2010, 10:39 AM. Reason: Meant intrabar .. not intraday

    Comment


      Great to hear, Belecona.

      This is possible, although a little challenging.

      To monitor the status of pt / stop loss orders, please see this reference sample:


      You can use principles of that reference sample to check fill state of these orders, and then use SendMail() to email.
      Ryan M.NinjaTrader Customer Service

      Comment


        Hi Ryan

        Your prompt response has made my day (as always). You're absolutely right that the monitoring pending PT/SL orders strategy sample is way too advanced for me (talking about IOrder etc).

        So, I will be happy to have an email alert when the strategy triggers a trade. Please confirm I have the following in good order so that I will add a similar code to Sell:

        Code:
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]AtmStrategyCreate(Cbi.Action.Buy, OrderType.Limit, Close[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]*TickSize, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], TimeInForce.Day, orderId, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"6E 15m"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], atmStrategyId);[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#008000]// Generates an email message[/COLOR] 
        SendMail("[email protected]", "[U]my email address here[/U]", "Trade Alert", "Buy 6E 15m Strategy");
        [/SIZE][/FONT][/SIZE][/FONT]
        Continue enjoying your day.

        Comment


          Yes, you have the SendMail in the same block that places the initial opening order, so looks good from here. I would confirm that this feature works for you using Tools > Options > Misc tab. Hit test to confirm that you can send mail with NinjaTrader.
          Ryan M.NinjaTrader Customer Service

          Comment


            Big Big Thank You for the email test suggestion. It works!!

            Now I will market replay my strategy and see if I may get an email alert when a trade is triggered. Wish me luck!

            Comment


              Good Luck!
              Ryan M.NinjaTrader Customer Service

              Comment


                Hi Ryan

                Thanks for your swift best wishes! Yes, it worked when I market replayed the strategy minutes ago. I got a Trade Alert email from NJ haha .. You make it HAPPENED! Thank you.

                Comment


                  Oh, almost forgot to ask you. Are there other mail alert options? Thanks Ryan.

                  Comment


                    SendMail() is the only one that can send mail. You can also use Alert() and it will log to the alerts window viewed through File > New > Alerts.

                    Some phone providers can receive email and send to your phone as SMS txt. You would have to check with your provider, but it's typically something like phone#@provider.com for the email address.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      Thanks Ryan for the additional tip. I talked to my phone service provider (after holding for 30 minutes for a live person) and my cell phone is too "old"! Well, I will find another way out.

                      I shared my email alert code with my friend. She tried to test the email confirmation with NJ first and got the following error message:

                      Test for email "Failed to send mail: error connecting to server.www.ninjatrader-support2.com"

                      How can she fix it please? Thank you.

                      Comment


                        Unfortunately it won't be compatible with all mail providers. She can check the settings under tools > options > Misc tab.

                        There's a thread here where people discussed setting up a yahoo singapore email account as a workaround:
                        Support for the development of custom automated trading strategies using NinjaScript.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          Hi Ryan

                          Mine is a gmail account (Canada) and hers too (she resides in California). Instead of creating a Yahoo Singapore account, how can we nail down the issue IF there's a way to uncover that? My trillion thanks again.

                          Comment


                            There are too many potential configurations to support this feature. It's dependent on your ISP as well. Some block the port used to send mail. All I can advise is check the settings. If she's looking for a solution to send with gmail, she may have to hire an IT professional to look at it.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              Hi Ryan

                              I already asked my friend to double-check her system setting etc etc. Thanks again. Have a Great Fri/Relaxing weekend. I'm done with my strategies' polishing (at least until further notice) and can relax now .. smile ..

                              Comment


                                Good morning Ryan

                                I need your help again (what's new ). I sim-ran the strategy with ATM strategy template and email alert overnight. The original one (without the additional codes) triggered a trade while the revised didn't!?? I did notice the error messages on the log (per enclosed).

                                I have the added codes as follows:

                                Code:
                                [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT]
                                [/SIZE][/FONT]
                                 
                                [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] atmStrategyId = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].Empty;[/SIZE][/FONT]
                                [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] orderId = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].Empty;[/SIZE][/FONT][/SIZE][/FONT]
                                Code:
                                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] OnBarUpdate()[/COLOR][/SIZE][/FONT]
                                [/SIZE][/FONT]
                                [FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//Condition set 1 Go Long[/COLOR][/SIZE][/FONT]
                                [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (orderId.Length == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && atmStrategyId.Length == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT]
                                [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&& CrossAbove(SlingShot(mAPeriod1,mAInput1,mAType1,mAPeriod2,mAInput2,mAType2).FastMA,[/SIZE][/FONT]
                                [SIZE=2][FONT=Courier New]SlingShot(mAPeriod1,mAInput1,mAType1,mAPeriod2,mAInput2,mAType2).SlowMA, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]))[/SIZE][/FONT]
                                [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
                                [SIZE=2][FONT=Courier New]debug ([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Entering Long"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
                                [SIZE=2][FONT=Courier New]atmStrategyId = GetAtmStrategyUniqueId();[/FONT][/SIZE]
                                [SIZE=2][FONT=Courier New]orderId = GetAtmStrategyUniqueId();[/FONT][/SIZE]
                                [SIZE=2][FONT=Courier New]AtmStrategyCreate(Cbi.Action.Buy, OrderType.Market, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], TimeInForce.Day, orderId, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"TF ST15m"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], atmStrategyId);[/SIZE][/FONT]
                                [SIZE=2][FONT=Courier New]DrawArrowUp([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Long"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + CurrentBar, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], Low[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] - ([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]4[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]*TickSize), Color.Lime);[/SIZE][/FONT]
                                [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//Generates an email message[/COLOR][/SIZE][/FONT]
                                [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]SendMail([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"[email protected]"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"[email protected]"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Trade Buy Alert"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Buy TF Slingshot 15m"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
                                [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
                                [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]


                                Don't worry about the } as I compiled the strategy successfully. When I market replayed the revised strategy on a few days' historical data, it did trigger trades + I got all email alerts. Appreciate your help. Have a great day.
                                Attached Files
                                Last edited by belecona; 09-10-2010, 04:27 PM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X