Topics
05 Dec 2014, 00:00
 2645
 1
Replies

admin
05 Oct 2012, 16:06

Hello,

 

A method for user-assigned identification of orders is under development right now and will be available in the next update. As far as automatic backtesting in running robots I need to ask you to please clarify what you mean. 

Find and Replace will be available in the near future as well.

We will think of your suggestion for a button to launch Visual Studio.

 


@admin

admin
05 Oct 2012, 11:55

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.IO;

namespace cAlgo.Robots
{
    [Robot]
    public class WriteToFileExample : Robot
    {
        StreamWriter _fileWriter;
    	
    	
        protected override void OnStart()
        {
			var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
			var filePath = Path.Combine(desktopFolder, "ServerTimeExample.txt"); 
			
			_fileWriter = File.AppendText(filePath);//creating file
			
			_fileWriter.AutoFlush = true;//file will be saved on each change
        }
        
        protected override void OnTick()
        {
			_fileWriter.WriteLine("Server Time: " + Server.Time);
        }
        
        protected override void OnStop()
        {
        	_fileWriter.Close();
        }
    }
}

 


@admin

admin
05 Oct 2012, 11:18

Hello,

 

In order to get historical data into a file you need to create a cBot that writes to a file and run it on back-testing mode.  

If you need to do this on a weekly basis choose the date for the back-testing to be a week and run the cBot once a week to append to the text file or create a new file.

See this post for a reference if you need help writing to a file: /forum/cbot-support/8

After you run this cBot and get the text file with the historical data you can run your other algorithm which presumably uses this historical data.

 


@admin

admin
03 Oct 2012, 11:14

Hello,

 

Please try the following:

 

In Connection Settings
Server
: http-proxy.ctrader.com
Port: 443
Protocol: HTTP
Use proxy to connect: Enabled (checked)

 


@admin

admin
03 Oct 2012, 09:25

Hello,

 

You can find the descriptions of all the trade methods here:

/docs/reference/calgo/api/internals/itrade

Click on each of the methods on the right menu to see an example.

 


@admin

admin
02 Oct 2012, 12:38

Yes. Please refer to Sample Buy Trailing and Sample Sell Trailing Robots in cAlgo as examples to code trailing stops.

 


@admin

admin
02 Oct 2012, 12:27

Bool will be added soon to the list of allowed Parameter types. 

 

In C# arrays are defined and initialized like this:

double[] posx = new double[200];

 


@admin

admin
02 Oct 2012, 12:21

Provided that the method Initialize() is a method defined in the rest of your code to perform trade operations, then your above assumption "to trade at specific times" is correct.

Otherwise, please clarify your question.

 


@admin

admin
27 Sep 2012, 18:06

Hello

 

The functionality to retrieve volumes will be available very soon. Stay tuned!

 


@admin

admin
26 Sep 2012, 15:10

Hello,

 

For backtesting purposes you can use MarketSeries.OpenTime:

 

    int index = MarketSeries.OpenTime.Count - 1;
    var stopTime = MarketSeries.OpenTime[index].Date.AddHours(22);


    if (MarketSeries.OpenTime.LastValue < stopTime)
    {
        Print("Server Time = {0}", Server.Time);
        // Open new positions                
    }



 


@admin

admin
25 Sep 2012, 10:29

No specific time yet but very soon. Stay tuned!

 


@admin

admin
25 Sep 2012, 09:50

Hello,

 

We do not have this feature at the moment. We will think about adding it in future releases. Thank you for your suggestion.

 


@admin

admin
25 Sep 2012, 09:47

The close is equal to the open because OnBar is executed at the begining of the current bar, so the close value is the same as the open, as well as the high and the low. What you need to do is investigate the previous bar.

 

You can test it with this code:

    // Previous Bar Index
    int previousIndex = MarketSeries.Close.Count - 2;
    // Previous Bar Open Time
    Print("Time: {0}", MarketSeries.OpenTime[previousIndex]);
    double cl = MarketSeries.Close[previousIndex];
    double op = MarketSeries.Open[previousIndex];
    double high = MarketSeries.High[previousIndex];
    double low = MarketSeries.Low[previousIndex];

    Print("cl: {0}", cl);
    Print("op: {0}", op);
    Print("high: {0}", high);
    Print("low: {0}", low);

    // Current Bar
    // The Bar just started so all values are equal to open
    cl = MarketSeries.Close.LastValue;
    op = MarketSeries.Open.LastValue;
    high = MarketSeries.High.LastValue;
    low = MarketSeries.Low.LastValue;

    Print("Time: {0}", MarketSeries.OpenTime.LastValue);
    Print("cl: {0}", cl);
    Print("op: {0}", op);
    Print("high: {0}", high);
    Print("low: {0}", low);



 


@admin

admin
24 Sep 2012, 19:55

Hello,

 

The parameters that you can change when you run a robot are defined in the code with the Parameter attribute, you may modify the code as you wish to add remove parameters.

You can also use the backtesting feature to see the results faster for testing purposes.  

You can try to download a robot again if it does not work properly sometimes users update the code.

From what I see the scalper does not depend on specific high timeframes, but we can troubleshoot the code and give you a faster version if possible. Stay tuned!

 


@admin

admin
24 Sep 2012, 19:21

Hello,

 

We will add functionality for identifying orders in our future releases as well as access to historical orders. Stay tuned.

 

For future reference, please post your suggestions in the "Feature Requests" category of the Forum so that we can better assist you.

 


@admin

admin
24 Sep 2012, 19:18

Hello,

 

The Trade methods return void. You will get a response if something goes wrong in the OnError event.  Otherwise a position will be opened or a pending order will be created in which case you can control execution in the events OnPositionOpened and OnPendingOrderCreated, respectively.

Access to historical orders as well as bool and other data types as input parameters is coming soon. Stay tuned.

Tracing through the code in debug mode is not possible for cAlgo in Visual Studio, but what you can do instead is use Print statements within your code so that you can troubleshoot your algorithms.

 

For future reference, please start a new Post for each question so that we can better assist you.

 


@admin

admin
24 Sep 2012, 19:03

Hello,

 

We will probably have to take a look at the indicator so that we can properly assist you.

 

Nonetheless, if based on the indicator SuperTrend uploaded on our site, I can tell that these two conditions will never be met:

if (upPrev > Symbol.Bid)  -> upPrev is set to the UpTrend of SuperTrend which is always below the price. UpTrend serves as a stop loss in a Buy Trade.

if (downPrev < Symbol.Bid) -> downPrev  is set to the DownTrend of SuperTrend which is always above the price. DownTrend  serves as a stop loss in a Sell Trade. 

 

In general, in order to troubleshoot your robots/indicators, you can add Print() statements in between your other code statements, so that for example, you can see if a specific condition is met or if a variable contains the value that it is intended to.

 

 


@admin

admin
24 Sep 2012, 17:29

The error I am seeing in your code is this: 

 

You are declaring a variable:

private  Position position ;

then you are referencing a variable that does not exist:

_position ==null

position and _position are two different names.

 

The easiest way to fix this is just change the declaration to:

private Position _position


@admin

admin
24 Sep 2012, 17:23

Hello,

 

Please try this code:

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Levels(0)]
    [Indicator]
    public class macdEmail:Indicator
    {
        private MacdCrossOver _macdCrossOver;
        private bool _emailSent;
        private string _from;
        private string _to;
        private string _subject;
        private string _text;

        [Parameter("Long Cycle", DefaultValue = 26)]
        public int LongCycle { get; set; }

        [Parameter("Short Cycle", DefaultValue = 12)]
        public int ShortCycle { get; set; }
        
        [Parameter("Period", DefaultValue = 9)]
        public int Period { get; set; }

        [Output("MACD")]
        public IndicatorDataSeries Macd { get; set; }

        protected override void Initialize()
        {
            _macdCrossOver = Indicators.MacdCrossOver(LongCycle, ShortCycle, Period);
            
            // Add your information below
            _from = "sender@...";
            _to = "receiver@...";
            _subject = "Macd Crossover";
            _text = "Crossed above";

        }

        public override void Calculate(int index)
        {
            Macd[index] = _macdCrossOver.MACD[index];

            // Make sure the email will be sent only at RealTime
            if (!IsRealTime)
                return;
            
            if (!_emailSent && _macdCrossOver.MACD[index - 2] < 0 && _macdCrossOver.MACD[index - 1] > 0)
            {                
                Notifications.SendEmail(_from,  _to, _subject, _text);
                Print(_text);
                _emailSent = true;
                return;
            }

            if(_emailSent && _macdCrossOver.MACD[index - 1] > 0 && _macdCrossOver.MACD[index] < 0)
            {
                _text = "crossed below";
                Notifications.SendEmail(_from, _to, _subject, _text);
                Print(_text);
                _emailSent = false;
            }

        }
    }
}



 


@admin

admin
24 Sep 2012, 12:49

Hello odomike,

 

This feature will be available very soon. Stay tuned.

 


@admin