Replies

ctid362975
07 Sep 2017, 15:07

Hi,

I do not need someone to code this for me.  If you could tell me how your VWAP / Position manager is working I can create the correct code.  But at the moment I cannot see thses classes fully as they are obfusucated. 

Otherwise I will wirite my own Position manager class.  Is that what you are suggesting I need to write my own PM class?

Thanks,


@ctid362975

ctid362975
07 Sep 2017, 15:05

Hi Guys,
I have checked and it is using Tick data for accuracy for the back test.  This error continues.

Thanks,


@ctid362975

ctid362975
05 Sep 2017, 15:32

RE:

Spotware said:

Dear Trader,

Thanks for your post. cBots currently do not support parameters of type long. This will be added in a future release of cAlgo. Please use int.

Best Regards,

c

Convert.ToInt64()

Thanks

Trader Team


@ctid362975

ctid362975
05 Sep 2017, 13:46 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE:

ctid362975 said:

Spotware said:

Dear Trader,

Thanks for posting in our forum. You equity at any time equals to the balance plus the unrealized net profit and loss. See screenshot below.

Here the equity is calculated with the following equation, €2500 + (-€4.72) = €2495.28.

In your case, what seems to be happening is that you are closing only profitable positions, causing the profit to be realized and your balance to be increased while the losing positions are keeping your equity low.

Best Regards,

cTrader Team

Thanks guys,

I have found my problem.  Perhaps you could further help.  I enter a short position market trades higher I sell again to average - i believe my entryPrice should be a VWAP.  So I am looking for the market to go down so I may take profit against my VWAP entry.  But, its only taking trade size from the 

 private long VolumeInUnits
        {
            get { return Symbol.QuantityToVolume(Quantity); }
        }

private void PlaceOrder()
{
 if (ActionType.Take == action.Type)
            {
                //Buy
                var takeProfit = GetPipsTarget(GetTimeZone(Time), TimeFrame, Direction.Buy);
                var stopLoss = GetPipsTargetStopLoss(GetTimeZone(Time), TimeFrame, Direction.Buy);;
                var result = ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, stopLoss, takeProfit, null, action.Comment);
                if (result.IsSuccessful)
                {
                    var position = result.Position;
                    Print("Position entry price is {0}", position.EntryPrice);
                }
                else
                {
                    if (!result.IsSuccessful)
                        Stop();
                }
            }
}

 

What I want it to do is take the total Short postion and close it without having to add any stoploss of takeProfit values.  

How should this be done?

Thanks,

Hey guys - I thinkg I have fixed this by converting all values from double to long and i send the volume amount that I want in a struct called action,

Thanks,

 


@ctid362975

ctid362975
05 Sep 2017, 11:32 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Spotware said:

Dear Trader,

Thanks for posting in our forum. You equity at any time equals to the balance plus the unrealized net profit and loss. See screenshot below.

Here the equity is calculated with the following equation, €2500 + (-€4.72) = €2495.28.

In your case, what seems to be happening is that you are closing only profitable positions, causing the profit to be realized and your balance to be increased while the losing positions are keeping your equity low.

Best Regards,

cTrader Team

Thanks guys,

I have found my problem.  Perhaps you could further help.  I enter a short position market trades higher I sell again to average - i believe my entryPrice should be a VWAP.  So I am looking for the market to go down so I may take profit against my VWAP entry.  But, its only taking trade size from the 

 private long VolumeInUnits
        {
            get { return Symbol.QuantityToVolume(Quantity); }
        }

private void PlaceOrder()
{
 if (ActionType.Take == action.Type)
            {
                //Buy
                var takeProfit = GetPipsTarget(GetTimeZone(Time), TimeFrame, Direction.Buy);
                var stopLoss = GetPipsTargetStopLoss(GetTimeZone(Time), TimeFrame, Direction.Buy);;
                var result = ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, stopLoss, takeProfit, null, action.Comment);
                if (result.IsSuccessful)
                {
                    var position = result.Position;
                    Print("Position entry price is {0}", position.EntryPrice);
                }
                else
                {
                    if (!result.IsSuccessful)
                        Stop();
                }
            }
}

 

What I want it to do is take the total Short postion and close it without having to add any stoploss of takeProfit values.  

How should this be done?

Thanks,


@ctid362975

ctid362975
01 Sep 2017, 17:12

RE:

Spotware said:

Dear Trader,

See an example below that might help. The logic of the example is to check enter criteria inside OnBar() event so that you enter the marker only once in each bar and to check exit criteria inside OnTick() so that you can exit the marker when your exit criteria are met. You can adjust the code accordingly.

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 bool _criteriaToEnter;
        private bool _criteriaToExit;
        protected override void OnStart()
        {
            // Put your initialization logic here
        }
        protected override void OnBar()
        {
            if (_criteriaToEnter)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
            }
        }
        protected override void OnTick()
        {
            if (_criteriaToExit)
            {
                ClosePosition(Positions[0]);
            }
        }

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

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

Best Regards,

cTrader Team 

Thanks Guys,

Something so simple.... I should have just stopped to think!  Awesome!


@ctid362975

ctid362975
01 Sep 2017, 13:55

RE:

Spotware said:

Dear Trader,

Thanks for posting in our forum. Your issue is related with your cBot's access rights which are declared in the cBot's attributes. You can find the guide for the access rights here.

More specifically, you need to change your cBot's access rights from AccessRights.None to AccessRights.FileSystem like the example below

 [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]

Best Regards,

cTrader Team

Thanks Guys - I did as you suggested and problem solved.

Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]

Cheers


@ctid362975