Topics
05 Dec 2014, 00:00
 2644
 1
Replies

admin
29 Nov 2012, 16:38

You may extend the class name of the robot you are trying to reference. 

 

//#reference: ..\Robots\test_Referenced.algo
// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//    Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------

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

namespace cAlgo.Robots
{
    [Robot]
    public class test_ReferenceRobot : test_Referenced
    {
        protected override void OnStart()
        {
        	base.Volume = 100;
            base.OnStart();
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}



// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//    Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------

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

namespace cAlgo.Robots
{
    [Robot]
    public class test_Referenced : Robot
    {
        [Parameter(DefaultValue = 10000, MinValue = 0)]
        public int Volume { get; set; }


        protected override void OnStart()
        {
            Print("test_Referenced Volume {0}", Volume);
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 



 


@admin

admin
29 Nov 2012, 12:36

I'm not sure why that is maybe you can share your code. In the meantime please test this and tell us if it solves your problem:

using System;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot]
    public class TestCreateBuyStopOrder:Robot
    {

        protected override void OnTick()
        {
            if(Trade.IsExecuting) return;
            double targetPrice = Symbol.Ask + Symbol.PipSize;

            if (Account.PendingOrders.Count == 0 && Account.Positions.Count == 0)
                Trade.CreateBuyStopOrder(Symbol, 1000, targetPrice, targetPrice - Symbol.PipSize, targetPrice + Symbol.PipSize, Server.Time.AddMinutes(10));
        }
        protected override void OnPendingOrderCreated(PendingOrder newOrder)
        {
            Print("Pending order created");
            Print("Stop Loss {0}", newOrder.StopLoss);
            Print("Take Profit {0}", newOrder.TakeProfit);

        }

        protected override void  OnPositionOpened(Position openedPosition)
        {
            Print("Position opened");
            Print("Stop Loss {0}", openedPosition.StopLoss);
            Print("Take Profit {0}", openedPosition.TakeProfit);
        }

        protected override void OnError(Error error)
        {
            Stop();
        }
    }
}




@admin

admin
29 Nov 2012, 11:42

We have this in our plans for future implementation.

 


@admin

admin
29 Nov 2012, 11:40

Thank you for your suggestions. We are going to take them into consideration for our future plans. 

 


@admin

admin
29 Nov 2012, 11:26

We will look into this. May we ask you which version you are using? For example is it Spotware cAlgo?

 


@admin

admin
29 Nov 2012, 11:17

The algo file is actually a dll file you can just rename it to .algo. Make sure you also set the namespace to be cAlgo.Robots/cAlgo.Indicators. You can set it as the default in the Application tab in the project properties in Visual Studio.

Let us know if you need more help.

 

 


@admin

admin
28 Nov 2012, 17:45

We could not reproduce the same so if you could please send us your code snippet so that we can investigate this we would be grateful.

 

 

@admin

admin
28 Nov 2012, 17:39

You can create a class library in c#. Make sure you add a reference to the cAlgo.API and that you are using .NET framework 4. You can build the project in visual studio and set the project output path to the folder where the indicators/robots are saved. This will create the algo file and then you will need to create an empty text (cs) file with the same name so that you can find it in the indicators/robots list and execute it there. Alternatively you may just copy paste the code into the cAlgo editor and just build it there. 

Let us know if you require additional help.

 


@admin

admin
28 Nov 2012, 17:32

The backtesting will be fixed this week. Unfortunately it is not possible to get a previous version.

 


@admin

admin
28 Nov 2012, 15:13

No currently there is no event associated with the expiration of pending orders. It will be implemented in the future.

 


@admin

admin
27 Nov 2012, 18:07

The reason it is crasshing is here:

bool longposition = position != null & position.TradeType == TradeType.Buy;            
bool shortposition = position != null & position.TradeType == TradeType.Sell;

It has to be corrected to this:

bool longposition = position != null && position.TradeType == TradeType.Buy;            
bool shortposition = position != null && position.TradeType == TradeType.Sell;

One more note, you would need this line

        public IndicatorDataSeries MarketTrend { get; set; }

instead of

        public double markettrend = 0;

in order to be able to access the values.


@admin

admin
27 Nov 2012, 17:21

No unfortunately not, but it will be fixed this week.

 


@admin

admin
27 Nov 2012, 09:45

It referes to a variable that has not been initialized. You may send us the code to point out exactly where the error is.

 


@admin

admin
26 Nov 2012, 17:55

Just correct it to this: Print("close=", MarketSeries.Close[MarketSeries.Close.Count-2]); 

 

int index = MarketSeries.Close.Count-1;

int prevIndex = index - 1;

open: MarketSeries.Open[prevIndex]

high: MarketSeries.High[prevIndex]

low: MarketSeries.Low[prevIndex]

close:MarketSeries.Close[prevIndex]

 

 


@admin

admin
26 Nov 2012, 12:27

It is on the top of our list. It should be very soon. We will keep you posted.

 


@admin

admin
26 Nov 2012, 12:25

Could you please post the code you are using to generate these results?

 

The OnBar event will generate the same values which are equal to the open price. You may use the previous to the last trendbar if this is the case.

 


@admin

admin
26 Nov 2012, 12:14

We are considering adding that into the list of acceptable input parameters.

 


@admin

admin
26 Nov 2012, 12:11

The reason is that there is no price movement during that time and therefore no trendbars are generated. If there is no trendbar the OnBar event will not be triggered.

 


@admin

admin
26 Nov 2012, 11:24

Thank you for the suggestion. We will consider it for the next updates.

 


@admin

admin
26 Nov 2012, 11:23

Your code is working properly. It may be a different issue.

If you are still experiencing problems let us know so that we can investigate further.

 


@admin