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

Setting up Strategy outgoing Email

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

    #16
    ok thanks, I actually had some of those + "" + at one time, Thanks so much

    Comment


      #17
      For those you are looking for the coded script

      SendMail(@"[email protected]", @"Subject Meassage here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));

      and this is the condition set I used to send the email once per trade

      Create a bool in variables " SendEmailONCE = false " , then where your strategy sends an Order to create a position in the "do the following area EnterLong() place the rule as addition action

      SendEmailONCE == false;

      these condition sets will then send the email for Long or Short positions created

      // Set 125
      if ((Position.MarketPosition == MarketPosition.Long)
      && (BarsSinceEntryExecution(0, "", 0) > -1)
      && (BarsSinceEntryExecution(0, "", 0) < 1)
      && (SendEmailONCE == false)

      // Condition group 1
      && (((Close[0] + (1 * TickSize)) > Position.AveragePrice)
      || ((Close[0] + (-1 * TickSize)) < Position.AveragePrice)))
      {
      SendMail(@"[email protected]", @"Subject Message here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));

      SendEmailONCE = true;
      }

      // Set 126
      if ((Position.MarketPosition == MarketPosition.Short)
      && (BarsSinceEntryExecution(0, "", 0) > -1)
      && (BarsSinceEntryExecution(0, "", 0) < 1)
      && (SendEmailONCE == false)

      // Condition group 1
      && (((Close[0] + (1 * TickSize)) > Position.AveragePrice)
      || ((Close[0] + (-1 * TickSize)) < Position.AveragePrice)))

      {

      SendMail(@"[email protected]", @"Subject Message Here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));
      SendEmailONCE = true;
      }


      Hope this helps someone and saves you some time.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pechtri, 06-22-2023, 02:31 AM
      9 responses
      122 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by frankthearm, 04-18-2024, 09:08 AM
      16 responses
      66 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by habeebft, Today, 01:18 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by benmarkal, Today, 12:52 PM
      2 responses
      14 views
      0 likes
      Last Post benmarkal  
      Started by f.saeidi, Today, 01:38 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X