PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
16 Feb 2018, 11:12

Hi Alexander,

Try something like this

            var source = MarketData.GetSeries(TimeFrame.Minute15).High;
            var _bb = Indicators.BollingerBands(source, 20, 2, MovingAverageType.Exponential);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Feb 2018, 09:30

Hi DelTrader, 

Thanks but probably this is not enough, As I said, it seems that your condition is never fulfilled. In order to understand why the condition is not fullfiled, we will need to know what values do the different variables have at the time when this line of code is reached. So the only way to do this is to actually debug the cBot. This means that we will need the full source code as well as the execution parameters (Symbol, timeframe etc). If you don't want to expose your cBot publicly, you can contact me at community@spotware.com.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Feb 2018, 09:18

Hi thoy1,

Just to make sure what you are asking for, you need this part 

        protected override void OnPositionClosed(Position last)
        {
            foreach (var position in Positions)
            {
                if (position.NetProfit > -1)
                {
                    ClosePosition(position);
                }
            }

not to trigger OnPositionsClosed again, right?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Feb 2018, 09:12

Hi thegreat.super,

Here s a guide that explains how to debug cBots in Visual Studio. Paul Hayes has also created a couple of cool videos on this subject. You can find one here

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 16:00

Hi dordkash@gmail.com,

You can use a boolean flag that will be reset on each OnBar() 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 15:26

Hi Medjan,

This is not in our current plans however I would recommend you to post it in our Suggestions section to be consdered for future releases.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 14:29

Hi dordkash@gmail.com,

Consider putting your logic in the OnTick()  function instead of in the OnBar().

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 14:12

Hi megamemo,

Thanks for the nice feedback and the clarifications as well. Maybe you would llke to contact a professional Consultant to help you with such a cBot or post a job in the Jobs section.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 10:49

Hi megamemo,

It is not very clear to us what you are looking for. Do you need a cBot that implements OCO? Please elaborate so that we can help you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 10:44

Hi DelTrader,

Most probably your condition is not fulfilled

 if (myPositionsSymbol1.Length <= (MaxOpenTradesSymbol1 - 1) && Symbol1Spread <= MaxSpreadSymbol1)
                {

However we cannot advise further if we don't know what this condition is supposed to do and what do the parameters mean. For example, we don't know what MaxOpenTradesSymbol1 or  LabelSymbol1 

Best Regards,

Panagiotis 


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 10:25

Hi JoaoRMartins,

This is a known issue and it is going to be resolved in the next release of the API.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Feb 2018, 10:13

Hi dordkash@gmail.com,

You have the following condition in OnBar()?

 

if (Symbol.Bid - MarketSeries.High.Last(1) > Symbol.PipSize)
    ExecuteMarketOrder(TradeType.Buy, Symbol, VOL, label, buypips, tp);

This code is executed as soon as a bar closes and a new one is created. This means that the first tick of the new bar should be 1 pip higher that the highest price of the last bar. Ever if the last tick of the previous bar was the highest price recorded for that bar, it is very unlikely that the first tick of the new bar will be 1 pip higher.

Best Regards,

Panagiotis 


@PanagiotisCharalampous

PanagiotisCharalampous
14 Feb 2018, 11:04

Hi dordkash@gmail.com,

Your code is located in the OnBar method. It is highly unlikely that the bid price will become higher by one pip from the previous high. Maybe you would like to reconsided your logic.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Feb 2018, 10:29

Hi thegreat.super,

Unfortunately, it is not easy to help you if I don't have the same conditions as you. I have provided a link above that explains what this exception means. Probably a variable is used somewhere without being initialized first or having a null value. If you try to debug this cBot using Visual Studio, then it will be easy to find out where the exception is thrown and fix it. 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Feb 2018, 10:06

Hi swingfish,

If you want to remove TP and SL from a position, you need to modify it and set the relevant fields to null. See below

 ModifyPosition(position, null, null);

A suggestion to improve your cBot's performance is to keep track of the open volume during position opening and closing so that you can avoid the loop that counts it.

Let me know if this helps you

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Feb 2018, 15:52

Hi Elias,

You can develop your cBot based on the example above. If you need professional help developing your cBot you can contact a Consultant or post a Job.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Feb 2018, 14:44

Hi luoyefengxing,

Please send us the cBot code and the backtesting configuration so that we can check and tell you why it stopped.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Feb 2018, 12:51

Hi Elias,

It is not very clear what you are trying to do since the code you have posted seems to be a mixup of a cBot and an Indicator. If you want to call the MACD Crossover indicator in a cBot, see a simple example below.

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        private MacdCrossOver _macdCrossOver;
        
        protected override void OnStart()
        {
            _macdCrossOver = Indicators.MacdCrossOver(28,12,9);
        }

        protected override void OnTick()
        {
            
        }

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

Let me know if this is what you are looking for.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Feb 2018, 11:15

Hi luoyefengxing,

Thanks for posting in our forum. Why do you say that cBot uses data only in 2014? What makes you think that?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Feb 2018, 11:10

Hi Alexander,

The cBot stops because of this condition

            if (StoppedByRobot == false)
            {
                Print("Sorry");
                Stop();
            }

What was your intention writing this part?

Best Regards,

Panagiotis


@PanagiotisCharalampous