Replies

JRWEnigmaPips
27 Mar 2013, 18:29

RE:
cAlgo_Fanatic said:

OnPositionOpened will be triggered for the positions opened by the same robot.

You could accomplish what you need with a robot that checks the account position count on each tick.

protected override void OnTick()
{
    if(_count != Account.Positions.Count)
    {
        if(_count < Account.Positions.Count)
            Notifications.SendEmail("email@gmail.com", "email@gmail.com", "Position Opened", "The position has been opened");
        _count = Account.Positions.Count;
        
    }
}



Hello I really appreciate this, thanks so much! WORKS GREAT!


@JRWEnigmaPips

JRWEnigmaPips
24 Mar 2013, 16:33

Hello,

 

I have been trading for 5 years, however only recently tried programming, I am trying to build an robot or indicator that does the following:

If I have manually set a pending order, and it is then opened, I would receive an email, stating that the position has been opened.

It's a simple concept but I can't get my head around doing it, I've attempted to produce this with the following: 

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot]
    public class emailer : Robot
    {
    	private Position position;
        
        protected override void OnPositionOpened(Position openedPosition)
        {
       		Notifications.SendEmail("email@gmail.com","email@gmail.com","Position Opened","The position has been opened");
            position = openedPosition;
        }

    }
}

 

I believe it may work better as an indicator, I just want to have this robot or indicator running so it sends a notification when a position has been opened.

 

I really appreciate the help in advance, and look forward to a response.

 

Thanks


@JRWEnigmaPips