Is it possible in C bot?

Created at 18 Mar 2024, 16:49
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FL

flappiyt

Joined 04.03.2024

Is it possible in C bot?
18 Mar 2024, 16:49


Is it possible in C bot? To close long trade without using short trades?

Can you give me simple example of how to use it? For example c bot opens 0.2 lots of something and it closes 50%(0.1 lot) of the trade after specific conditions are met.


@flappiyt
Replies

firemyst
22 Mar 2024, 01:06 ( Updated at: 22 Mar 2024, 07:52 )

TO change the volume, use the ModifyVolume method;

To close a position entirely, use the Close method.


@firemyst

flappiyt
23 Mar 2024, 19:17 ( Updated at: 25 Mar 2024, 06:43 )

RE: Is it possible in C bot?

firemyst said: 

TO change the volume, use the ModifyVolume ;

To close a position entirely, use the Close method.

Hi firemyst 

I have no idea how to use ModifyVolume 

Could you please help me to implement it into my code? 

I tried something like this but it fails 

if (!isPartialCloseExecuted && isAlreadyInTrade)
                    {
                        double closePositionSize = positionSize * 0.5;
                        
                        public abstract TradeResult ModifyVolume(double closePositionSize)

                        isPartialCloseExecuted = true;
                    }


@flappiyt

PanagiotisCharalampous
25 Mar 2024, 07:10

RE: RE: Is it possible in C bot?

flappiyt said: 

firemyst said: 

TO change the volume, use the ModifyVolume ;

To close a position entirely, use the Close method.

Hi firemyst 

I have no idea how to use ModifyVolume 

Could you please help me to implement it into my code? 

I tried something like this but it fails 

if (!isPartialCloseExecuted && isAlreadyInTrade)
                    {
                        double closePositionSize = positionSize * 0.5;
                        
                        public abstract TradeResult ModifyVolume(double closePositionSize)

                        isPartialCloseExecuted = true;
                    }

Hi there,

Here is an example

            var position  = ExecuteMarketOrder(TradeType.Sell, SymbolName, 2000).Position;
            position.ModifyVolume(1000);

@PanagiotisCharalampous