Topics
16 Nov 2023, 07:42
 1088
 1
15 Nov 2023, 10:36
 1967
 16
Replies

Spotware
29 Oct 2013, 11:32

RE: RE:

jhtrader said:

Question 1.

Access the last 10 highs - no matter what I do I cant seem to get the real highs and lows as on the chart..

            for (int i = MarketSeries.High.Count - 1; i > MarketSeries.High.Count - 11; i--)
            {
                Print("Val H {0}", min5.High[i]);

           }

See the example for GetIndexByDate here: /forum/whats-new/1463#3

The code above prints the High of the min 5 timeframe. The chart will have the prices of the timeframe chosen when you add the instance of the robot.

I also just tried to get the last high.. in the following way.. and it too didnt work.

Print("Val H {0}", min5.High[min5.High.Count - 1]);

min5.High.LastValue

Question 2.

How to put these values into a list. so that the values are cumulative

List<double> cummulativeHighs = new List<double>();
//...
cummulativeHighs.Add(min5.High.LastValue + cummulativeHighs.LastOrDefault());

Question 3.

loop through and compare until currRange < cummulative range and return the index.

See the previous reply post.


@Spotware

Spotware
29 Oct 2013, 11:07

RE:

jhtrader said:

Hi,

I am looking for some help on a problem.

I would like to compare the current range to the cumulative range of the last 10 bars.

While

current range x > Range(x-1)

current range x > Range(x-1) + Range (x-2)

current range x > Range(x-1) + Range (x-2) + Range (x-3)

....

when the condition is false it returns the last index. so if the current range is greater than the cumulative range of the last 4 bars it returns 5.

Issues

The Highs that are reported are not the same as on the screen

Make sure you choose min 5 Timeframe for the robot instance.

private readonly List<double> _Cumm5 = new List<double>(10);

min5 = MarketData.GetSeries(Symbol.Code, TimeFrame.Minute5);

   for (int i = 1; i < 11; i++)
            {
                // _Cumm5[i - 1] = min5.High[min5.High.Count - i] - min5.Low[min5.Low.Count - i] + _Cumm5[i];
                //Print("Val H {0}", min5.High[min5.High.Count - i]);
                Print("{0}", _Cumm5.Count);
                double H = min5.High[min5.High.Count - i];
                double L = min5.Low[min5.Low.Count - i];
                double Ct = min5.High.Sum(i);
                // Print("Val L{0}", min5.Low[min5.Low.Count - i]);
               // _Cumm5.Add(H - L);
                //Print("Cumm: {0}", _Cumm5[i].ToString());
                Print("H {0}", H);

                Print("L {0}", L);

                Print("Rng {0}", H - L);

            }

I cannot seem to get the list working it loops infinitely

It is not clear what you mean by loops infinitely. If you are referring to the for loop, the syntax is correct, i.e. it does not create an infinite loop.
If you are adding this code in the OnTick method it will be called on each tick.
If you mean it does not break out of the loop when the condition is met, then you need to add the condition inside the loop and if it is met you will break out of the loop.

Try this code:

        protected override void OnBar()
        {
            double cummulativeRange = 0;
            int min5Count = min5.High.Count; 

            for (int i = 1; i < 11; i++)
            {
                double H = min5.High[min5Count - i];
                double L = min5.Low[min5Count - i];

                double range = H - L;
                cummulativeRange += range;

                if (range < cummulativeRange)
                {
                    Print("min5Count {0}", min5Count);
                    Print("min5Count - i {0}, i {1}, range {2}, cumRange {3}", min5Count - i, i, range, cummulativeRange);
                    break;
                }
            }            
        }

 


@Spotware

Spotware
29 Oct 2013, 11:02

Could you send us backtesting cache files from both computers to engage@spotware.com - we will check what exactly happen.


@Spotware

Spotware
29 Oct 2013, 10:39

RE:
 var koopn = new MarketOrderRequest(TradeType.Buy, lots);
 koopn.SlippagePips = 1;
 koopn.Label = _LABEL;
 Trade.Send(koopn);

After the example above, i would like to get the object of this trade as a Position, if the marketorderrequest is executed. Is there a shortcut?

Like:

Position pos = koopn...

 

What you described here is synchronous API - your code need to wait until position is open. Currently cAlgo supports only asynchronous API so you have to use separate method to handle trade result. Right now we are improving our trading API - in the nearest future you will be able to choose synchronous API as well. In that way your code will look like this:

 

TradeResult result = ExecuteMarketOrder(TradeType.Buy, Symbol, lots, _LABEL, null, null, slippagePips: 1);
Position position = result.Position;

@Spotware

Spotware
28 Oct 2013, 17:56

First of all, one possible reason of this behavior is incorrect backtesting data. You can remove your backtesting cache and try to test robots one more time. Please do not remove cache completely, you can send it to us for further investigation.

We also suggest you to investigate actual robot behavior with backtesting chart. What exactly is wrong there? Some positions were not open? Opened at different price? Closed at different prices? Are indicator values the same or not? We can help you to investigate this if you send us your code (may be partially), discretion of how your strategy must behave, screenshots of charts, logs or something else that can be useful.


@Spotware

Spotware
25 Oct 2013, 10:11

This has been fixed. Please try again.


@Spotware

Spotware
25 Oct 2013, 10:10

This can be resolved by updating to Windows 8.1.


@Spotware

Spotware
24 Oct 2013, 15:38

Please see if the following helps:
1. Look at the backtesting chart - are there trend bars for this period?
2. Remove the backtesting cache - try again


@Spotware

Spotware
24 Oct 2013, 15:19

We are working on this feature right now and it will be released in future versions. For now you have to hard code it.


@Spotware

Spotware
24 Oct 2013, 14:57

The results may depend on the robot logic. If you like send us the code or code snippet to engage@spotware.com.


@Spotware

Spotware
24 Oct 2013, 12:55

We expect the fix to be released approximately in two weeks, but this plan can be changed.


@Spotware

Spotware
24 Oct 2013, 12:22

RE:

supafly said:

Has anyone here tried to simulare their algos on the platforms listed below and get similar results? How much can prices vary? Shouldn't prices be roughly the same? How do I know that the live data feed from the broker is not tampered with?

Just a note to all the forum readers, I have been informed from a reliable source that some brokers smooth the prices on spikes.

1.spotwares calgo
2.fxpro's calgo
3.liquidmarkets calgo

Brokers can have different Liquidity Providers and therefore there will be differences in execution. In fact, the same Liquidity Providers can stream different feeds to different clients.


@Spotware

Spotware
24 Oct 2013, 12:08

Thank you for the suggestion but we do not currently plan to modify the current color palette.


@Spotware

Spotware
23 Oct 2013, 15:36

In the next version we will add a new property to the Symbol class: PipValue - the amount of profit that you gain or lose when the price goes up or down one pip so this task will be much easier. Right now, you will need to convert your possible loss from the quote currency of the symbol to your deposit currency.


@Spotware

Spotware
23 Oct 2013, 14:48

There is no such API but we have an idea to implement an API allowing one robot to start and stop other robots.


@Spotware

Spotware
23 Oct 2013, 14:31

No, but you can request series of another timeframe.

If you need something else please explain what exactly do you want in give an example in which situation it can be useful.


@Spotware

Spotware
23 Oct 2013, 12:52

You can set a boolean field in the OnPositionClosed method and then check if you can open positions.

Set the boolean field:

         private bool isOpenPositionsPermitted;

        protected override void OnStart()
        {
            Positions.Closed += OnPositionsClosed;
        }

        void OnPositionsClosed(PositionClosedEventArgs args)
        {
            isOpenPositionsPermitted = false;
        }

Check if the position is closed in the OnTick/OnBar events or your user defined method which opens positions:

if(isOpenPositionsPermitted)
{
  // Your logic to open positions
}

Reset the boolean field to false according to your algorithm logic. If you want to count 10 bars then set a variable in the  OnPositionsClosed to the bar count:

        private int barCountSinceLastPosition;

        void OnPositionsClosed(PositionClosedEventArgs args)
        {
            isOpenPositionsPermitted = false;
            barCountSinceLastPosition = MarketSeries.Close.Count;
        }

Check if the bar count value against the current bar in the OnTick/OnBar events or your user defined method which opens positions:

if (MarketSeries.Close.Count - barCountSinceLastPosition >= 10)
{
    isOpenPositionspermitted = true;
}

 


@Spotware

Spotware
23 Oct 2013, 12:31

Thank you for your suggestions. The two recommendations are already included in our plans.


@Spotware

Spotware
23 Oct 2013, 12:08

It has to be added in the OnPendingOrderCreated method. 
cAlgo uses asynchronous operation. So, after it sends the request for a pending order with Trade.CreateBuyStopOrder to the server, the order will not have been created when the execution reaches the next statements  if (LastOrderSuccessful)...            

protected override void OnPendingOrderCreated(PendingOrder newOrder)
{
    _PendingPositions.Add(newOrder);
}

See:
/api/robot/onpendingordercreated-26ec

One more note on C# syntax:
This is not a proper call to a method: _PendingPositions.Add(PendingOrder order);
The above statement will produce a compiler error.
It has to be _PendingPositions.Add(order); 

When you declare methods you need to specify the parameter types:

This is a method declaration:

protected void myMethod(PendingOrder newOrder)
{
    _PendingPositions.Add(newOrder);
}

When you call methods you omit the parameter types. Only the variable name is necessary in the parameter list:
This is a method call:

PendingOrder order = Account.PendingOrders[0]; 
myMethod(order); // This is a method call
myMethod(PendingOrder  order); // This is wrong syntax

See also:
http://msdn.microsoft.com/en-us/library/ms173114.aspx
http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx


@Spotware

Spotware
23 Oct 2013, 09:40

What about Indicators folder? Have you tried to rename it?


@Spotware