Topics
18 Mar 2024, 16:49
 224
 3
18 Mar 2024, 15:58
 232
 5
18 Mar 2024, 15:48
 163
 2
18 Mar 2024, 15:36
 171
 1
04 Mar 2024, 17:50
 122
 0
04 Mar 2024, 17:50
 136
 3
Replies

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

flappiyt
21 Mar 2024, 16:01

RE: RE: RE: Is it possible in C bot?

PanagiotisCharalampous said: 

flappiyt said: 

PanagiotisCharalampous said: 

Hi there,

Yes it is. You need to calculate your candle's duration and then detect when the upcoming closing time is closer that 10 seconds, then execute your logic.

Best regards,

Panagiotis

Hi Panagiotis

Could you please tell me how to do that? Do I have to start the bot at the exact hour, like 15:35:00, and then calculate it, or is there an easier way? The bot will be opening trades on a 5-minute chart.

I have created a bot like this, but it only prints "Green candle" after the candle closes; it prints it at exact hours not 10 s before.

 

using System;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class BOT : Robot
    {
        int PeriodInSeconds = 300;
        int Seconds = 10;
        
        protected override void OnBar() // On tick doesn't work either
        {
            var timeToClose = PeriodInSeconds - (Server.Time - MarketSeries.OpenTime.Last(1)).TotalSeconds;

            if (timeToClose <= Seconds)
            {
                var lastCandle = MarketSeries.Open.Last(1);
                if (lastCandle > MarketSeries.Close.Last(1))
                {
                    Print("Green candle");
                }
            }
        }
    }
}
 

Hi there,

Unfortunately I cannot write the code for you. If you need professional assistance, you can contact a consultant

Best regards,

Panagiotis

Hi Panagiotis

I don't want you to write code for me, I only want to ask what methods are used to implement this in C#.


@flappiyt

flappiyt
19 Mar 2024, 15:53 ( Updated at: 19 Mar 2024, 16:00 )

RE: Is it possible in C bot?

PanagiotisCharalampous said: 

Hi there,

Yes it is. You need to calculate your candle's duration and then detect when the upcoming closing time is closer that 10 seconds, then execute your logic.

Best regards,

Panagiotis

Hi Panagiotis

Could you please tell me how to do that? Do I have to start the bot at the exact hour, like 15:35:00, and then calculate it, or is there an easier way? The bot will be opening trades on a 5-minute chart.

I have created a bot like this, but it only prints "Green candle" after the candle closes; it prints it at exact hours not 10 s before.

 

using System;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class BOT : Robot
    {
        int PeriodInSeconds = 300;
        int Seconds = 10;
        
        protected override void OnBar() // On tick doesn't work either
        {
            var timeToClose = PeriodInSeconds - (Server.Time - MarketSeries.OpenTime.Last(1)).TotalSeconds;

            if (timeToClose <= Seconds)
            {
                var lastCandle = MarketSeries.Open.Last(1);
                if (lastCandle > MarketSeries.Close.Last(1))
                {
                    Print("Green candle");
                }
            }
        }
    }
}
 


@flappiyt

flappiyt
11 Mar 2024, 14:14

RE: C bot acts wierd when backtesting

PanagiotisCharalampous said: 

Hi there,

What you see on the screenshots is possible and is is called slippage. Stop losses are never guarranteed. The stop loss level is just a trigger level. Where exactly the stop loss will be triggered, depends on the market.

Best regards,

Panagiotis

Hi 

I know that, but as I said, it also happens when there aren't such big candles. It was an example, and I don't think that it is normal for a trade to be executed 11 times too slow. Also, when I was trading live without a bot, if there were such moves, I wasn't losing that much.


@flappiyt

flappiyt
05 Mar 2024, 12:19 ( Updated at: 05 Mar 2024, 13:28 )

RE: C bot problem

PanagiotisCharalampous said: 

Hi there,

Please provide more information about your problem. What do you mean when you say “I noticed that it's opening positions, but I can't see them”?

Best regards,

Panagiotis

Hi Panagiotis

I can hear positions being opened, and I can see it in the top right corner. However, I noticed in the trading history that positions are being opened for approximately 0.001 seconds and are immediately closed.


@flappiyt

flappiyt
05 Mar 2024, 12:17 ( Updated at: 05 Mar 2024, 13:28 )

RE: Smaller stop loss than expected

PanagiotisCharalampous said: 

Hi there,

SL and TP should be set in pips. You seem to pass absolute prices instead.

Best regards,

Panagiotis

Hi Panagiotis

I am new to C# can you tell me how to make the program to calculate stop loss in pips instead off absolute prices?


@flappiyt

flappiyt
04 Mar 2024, 17:50 ( Updated at: 05 Mar 2024, 06:44 )

Hi, recently I made a C-bot in cAlgo, and it seemed to work well during backtesting. However, when I applied it to a live chart, I noticed that it's opening positions, but I can't see them. The last time I created a bot, I was able to view the positions. Can you help me?


@flappiyt

flappiyt
04 Mar 2024, 17:50 ( Updated at: 05 Mar 2024, 06:44 )

Hi, recently I made a C-bot in cAlgo, and it seemed to work well during backtesting. However, when I applied it to a live chart, I noticed that it's opening positions, but I can't see them. The last time I created a bot, I was able to view the positions. Can you help me?


@flappiyt

flappiyt
04 Mar 2024, 17:50 ( Updated at: 05 Mar 2024, 06:44 )

Hi, recently I made a C-bot in cAlgo, and it seemed to work well during backtesting. However, when I applied it to a live chart, I noticed that it's opening positions, but I can't see them. The last time I created a bot, I was able to view the positions. Can you help me?


@flappiyt

flappiyt
04 Mar 2024, 17:50 ( Updated at: 05 Mar 2024, 06:44 )

Hi, recently I made a C-bot in cAlgo, and it seemed to work well during backtesting. However, when I applied it to a live chart, I noticed that it's opening positions, but I can't see them. The last time I created a bot, I was able to view the positions. Can you help me?


@flappiyt