GD
GDPR-24_203122
Blocked user by Spotware at 12 Jan 2024, 08:52
0 follower(s) 0 following 0 subscription(s)
Replies

GDPR-24_203122
11 Sep 2016, 22:36

About Senkou A & B

Hi!

I often use the Crosshair tool to check indicator lines and stuff. It has a vertical and horizontal line. If you plan on using ichimoku in your bot, you should also consider, that the Kumo (the Cloud from senkou A&B) is drawn late (26 periods on default, I think) in the chart. That means that if you want to see, for example, if the price is above the Cloud at a certain point in time, you need to check the Senkou A & B from 26 periods past, not their last value.


GDPR-24_203122
11 Sep 2016, 22:25

RE:

croucrou said:

Okay, it looks like only data series can be output. If creating a new one basing on the up/down conditon is not the solution, I would consider it a buggy situation.

Okay, thanks for informing.

:-)


GDPR-24_203122
05 Sep 2016, 00:13

RE:

croucrou said:

Shouldn't it be:

Print("LatestHAClose:", _heikenAshi.haClose.Last(1));
Print("LatestHAOpen:", _heikenAshi.haOpen.Last(1));

instead of:

Print("LatestHAClose:", _heikenAshi.haClose[1]);
Print("LatestHAOpen:", _heikenAshi.haOpen[1]);

Hmm. No, it doesn't work that way, but it doesn't matter anymore. I noticed I can probably get approx. the same results using the (standard issue) Accumulative Swing Index -indicator, and watching the correlating levels, concerning HeikenAshiSmooth-indicator turning either red or blue. About 

There were other posts about the problem I had (finding the right output) but they did not get them working. Other similar was with Super Trend indicator.

The indicator's drawn line is also not the same in real time, as it is looking backwards in the chart, because mathematical functions are applied later on, so it's tricky. It "lies", so to speak.

 

PS: Keep pushing on!

 

 


GDPR-24_203122
18 Jun 2016, 14:28

This post was removed by moderator.


GDPR-24_203122
03 Jun 2016, 13:08

RE:

 

I tried making a robot of this indicator that opens buys when "TimeToBuy" = true and sells when "TimeToBuy = false, and closes the other trade when the it reverses. 

There is a problem in OnStart, "parameters count", when invoking the indicator. I'm not sure how and which of the parameters should be included. Of course the finished bot shouldn't have any stop loss or take profit, but they are here now (even duplicated), on this test code of the robot (below the indicator). If anyone has spare time, I guess this might be worth while to look into... Also please post a reply, if you can fix it...

Indicator:

using System;
using cAlgo.API;
using System.Runtime.InteropServices;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SuperProfit : Indicator
    {
        // Alert
        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);

        [Parameter(DefaultValue = 35)]
        public int DllPeriod { get; set; }

        [Parameter(DefaultValue = 1.7)]
        public double Period { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Weighted)]
        public MovingAverageType MaType { get; set; }

        [Parameter()]
        public DataSeries Price { get; set; }

        [Parameter(DefaultValue = 5)]
        public int StopLoss { get; set; }

        [Parameter(DefaultValue = 20)]
        public int TakeProfit { get; set; }

        [Output("Up", PlotType = PlotType.Points, Thickness = 4)]
        public IndicatorDataSeries UpSeries { get; set; }

        [Output("Down", PlotType = PlotType.Points, Color = Colors.Red, Thickness = 4)]
        public IndicatorDataSeries DownSeries { get; set; }

        public bool TimeToBuy;

        private DateTime _openTime;

        private MovingAverage _movingAverage1;
        private MovingAverage _movingAverage2;
        private MovingAverage _movingAverage3;
        private IndicatorDataSeries _dataSeries;
        private IndicatorDataSeries _trend;


        protected override void Initialize()
        {
            _dataSeries = CreateDataSeries();
            _trend = CreateDataSeries();

            var period1 = (int)Math.Floor(DllPeriod / Period);
            var period2 = (int)Math.Floor(Math.Sqrt(DllPeriod));

            _movingAverage1 = Indicators.MovingAverage(Price, period1, MaType);
            _movingAverage2 = Indicators.MovingAverage(Price, DllPeriod, MaType);
            _movingAverage3 = Indicators.MovingAverage(_dataSeries, period2, MaType);

        }

        public override void Calculate(int index)
        {
            if (index < 1)
                return;

            _dataSeries[index] = 2.0 * _movingAverage1.Result[index] - _movingAverage2.Result[index];
            _trend[index] = _trend[index - 1];

            if (_movingAverage3.Result[index] > _movingAverage3.Result[index - 1])
                _trend[index] = 1;
            else if (_movingAverage3.Result[index] < _movingAverage3.Result[index - 1])
                _trend[index] = -1;

            if (_trend[index] > 0)
            {
                UpSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] < 0.0)
                {
                    UpSeries[index - 1] = _movingAverage3.Result[index - 1];

                    if (IsLastBar)
                    {
                        var stopLoss = MarketSeries.Low[index - 1] - StopLoss * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] + TakeProfit * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            _openTime = MarketSeries.OpenTime[index];
                            //                      DisplayAlert("Buy signal", takeProfit, stopLoss, entryPrice);
                            TimeToBuy = true;
                        }
                    }
                }

                DownSeries[index] = double.NaN;
            }
            else if (_trend[index] < 0)
            {
                DownSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] > 0.0)
                {
                    DownSeries[index - 1] = _movingAverage3.Result[index - 1];

                    if (IsLastBar)
                    {
                        var stopLoss = MarketSeries.High[index - 1] + StopLoss * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] - TakeProfit * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            _openTime = MarketSeries.OpenTime[index];
                            //                      DisplayAlert("Sell signal", takeProfit, stopLoss, entryPrice);
                            TimeToBuy = false;
                        }
                    }
                }

                UpSeries[index] = double.NaN;
            }

        }

        protected void DisplayAlert(string tradyTypeSignal, double takeProfit, double stopLoss, double entryPrice)
        {
            string entryPricetext = entryPrice != 0.0 ? string.Format(" at price {0}", Math.Round(entryPrice, 4)) : "";
            string takeProfitText = takeProfit != 0.0 ? string.Format(", TP on  {0}", Math.Round(takeProfit, 4)) : "";
            string stopLossText = stopLoss != 0.0 ? string.Format(", SL on {0}", Math.Round(stopLoss, 4)) : "";

            var alertMessage = string.Format("{0} {1} {2} {3} {4}", tradyTypeSignal, entryPricetext, takeProfitText, stopLossText, Symbol.Code);

            MessageBox(new IntPtr(0), alertMessage, "Trade Signal", 0);

        }
    }
}

Robot:

 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 SuperProfitBot : Robot
    {

        [Parameter(DefaultValue = 1000)]
        public int Volume { get; set; }

        [Parameter("Source")]
        public DataSeries SourceSeries { get; set; }

        [Parameter(DefaultValue = 35)]
        public int DllPeriod { get; set; }

        [Parameter(DefaultValue = 1.7)]
        public double Period { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Weighted)]
        public MovingAverageType MaType { get; set; }

        [Parameter()]
        public DataSeries Price { get; set; }

        [Output("Up", PlotType = PlotType.Points, Thickness = 4)]
        public IndicatorDataSeries UpSeries { get; set; }

        [Output("Down", PlotType = PlotType.Points, Color = Colors.Red, Thickness = 4)]
        public IndicatorDataSeries DownSeries { get; set; }

        [Parameter("TP (pips)", DefaultValue = 500)]
        public int TP { get; set; }
        [Parameter("SL (pips)", DefaultValue = 500)]
        public int SL { get; set; }


        private SuperProfit _SuperProfit;



        protected override void OnStart()
        {
            _SuperProfit = Indicators.GetIndicator<SuperProfit>(DllPeriod, Period, MaType, Price, 100, 100);

        }




        protected override void OnBar()
        {

            if (_SuperProfit.TimeToBuy == true)
            {
                Print("Buy");
                //            foreach (var position in Positions)
                //           {
                //               if (position.TradeType == TradeType.Sell)
                //               {
                //                   ClosePosition(position);
                //                }
                //           }
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Label", SL, TP);
            }

            if (_SuperProfit.TimeToBuy == false)
            {
                Print("Sell");

                //            foreach (var position in Positions)
                //            {
                //                if (position.TradeType == TradeType.Buy)
                //                {
                //                   ClosePosition(position);
                //                }
                //            }
                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Label", SL, TP);
            }
        }
    }
}


GDPR-24_203122
24 May 2016, 20:41

RE:

tmc. said:

Let me know if it returns same values as original indicator.

Almost, but not exactly. I tried the different methods..


GDPR-24_203122
22 May 2016, 23:01

RE:

tmc. said:

I recommend using LINQ query operations.

using System.Linq;

var position = Positions.OrderByDescending(x => x.GrossProfit).Last();

 

Great, thanks a lot!


GDPR-24_203122
22 May 2016, 23:00

RE:

tmc. said:

Hey, what indicator is it? Maybe it would be worth converting it properly instead of using automated conversion.

Hey.

 

It's called "Slope Direction Line". It draws a single line, which has two colors to announce the trend. 


GDPR-24_203122
22 May 2016, 18:07

RE:

croucrou said:

Maybe you are looking for the Minimum of Position.GrossProfit?

Croucrou, yes that would do it. 

How to get the position, with the minimum GrossProfit?

 

Should either of these be used first?:

1. foreach (var Position in Positions)

2. Position[] positions = Positions.FindAll(Label, Symbol);

 

THANKS!


GDPR-24_203122
21 May 2016, 12:10

RE:

Stokes Bay Trading said:

Current method. Open 1 lots pay $2 commission, say. Close 1 lot. Open 2 lots pay $4 commission. Total $6

Suggested method. Open 1 lot pay $2 commission. Open another 1 lot, pay $2 commission. Total $4.

 

 

Usually the commission is relative to the volume, so making more trades would not matter. I've heard some brokers have a fixed commission, which stays the same regardless of the volume. 

When I started studying these robots, I read somewhere that in my case I have a commission on 90/million. So in testing robots, I set the commission to 45, because it also read that's how it should be done. (Can anyone clarify if I'm wrong with this?) 

PS: Actually now I think its better to learn to trade manually. And if it works, code it later... Managing takeprofit and stop loss feels too difficult by just coding, because of many factors which influence the high and lows, like support lines, even from weeks ago, round numbers etc.

 


GDPR-24_203122
14 May 2016, 11:54

RE:

galafrin said:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class SampleSMA : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Turquoise)]
        public IndicatorDataSeries Result { get; set; }

        double sum = 0 ;
        

public override void Calculate(int index)
        {

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i]  ) / 3.0 ;
            }
            Result[index] = sum / Periods;
        }
    }
}

Hello there and thak's a lot for the answer :)

 

 


GDPR-24_203122
01 May 2016, 14:50

RE: RE: RE:

ilpoj said:

noleenforex said:

Cakrawala said:

hi.

i just updated my cAlgo.. but it can't connect to network..i check my internet connection all running normal for browsing etc. any body same story with me?
 

Me too. Have the same problem? Anyone got this sorted out? if yes, how?

I cannot connect too. There were different errors. A totally new one also. "Error connecting to CTID". Usually the platform connects automatically, at least when the market data is streaming: monday to friday. There seems to be more login problems on weekends. Or my account may be connected with my ID (top right corner), but the demo-accounts can't connect (top left corner). Then I also can't optimize or backtest. The buttons are grayed out. There has been loss of connection to demo account even on normal weekdays, when I have a bot running. But I suppose also that my automatic antivirus- and antispyware-updates (spybot-sd) may cause connection loss sometimes. Sometimes restarting Calgo solves the problem. Now it doesn't.... 

Now it works. Automatic login with ID and demo-account!


GDPR-24_203122
01 May 2016, 09:28

RE: RE:

noleenforex said:

Cakrawala said:

hi.

i just updated my cAlgo.. but it can't connect to network..i check my internet connection all running normal for browsing etc. any body same story with me?
 

Me too. Have the same problem? Anyone got this sorted out? if yes, how?

I cannot connect too. There were different errors. A totally new one also. "Error connecting to CTID". Usually the platform connects automatically, at least when the market data is streaming: monday to friday. There seems to be more login problems on weekends. Or my account may be connected with my ID (top right corner), but the demo-accounts can't connect (top left corner). Then I also can't optimize or backtest. The buttons are grayed out. There has been loss of connection to demo account even on normal weekdays, when I have a bot running. But I suppose also that my automatic antivirus- and antispyware-updates (spybot-sd) may cause connection loss sometimes. Sometimes restarting Calgo solves the problem. Now it doesn't.... 


GDPR-24_203122
20 Apr 2016, 21:11

RE:

Spotware said:

Dear Trader,

Could you please provide us with more information regarding your issue and provide us with a reason why you believe the tick data you receive from the server during optimization is not accurate?

I cannot exactly say that the data would be "faulty" and I'm not claiming that, but there seems to be some very special market/price conditions on a 2 month period in 2015, that give enormously different type of test result than any other period in the past 2 years. I believe it's already explained in the other thread: "Bad tick data ?"

/forum/calgo-support/7701


GDPR-24_203122
06 Mar 2016, 10:59

RE:

cyfer said:

How to round decimal numbers in C# like you do in C language ?

Print(Math.Round(14.125,0)); //--> Returns a 14  in C#
Print(Math.Round(14.935, 0)); //--> Returns 15

and If you want to Round it so it has some decimal points you can specify that in the 2nd parameter of Round Method .

 

Thanx!


GDPR-24_203122
24 Feb 2016, 21:23

RE: :)

mindbreaker said:

So what ilpoj,

if there was no need to wonder.

Better earn 10 000$ than 2 000$ (doing nothing and not guarding anything).

You're wasting your time like I used to. If you set positions only on levels of 500 pips (you've got to think very rarely - especially eurusd, a currency for slowpoke )

In this week only 3 days i earn only 2 500$  on 1 lot.

Have a nice day.

 

 

Thanks for your tip Mindbreaker!

That sounds good but what if it goes the opposite direction? What do you mean you don't have to worry about it?

PS: By the way I got an insight today on how to smooth the "ride" and made an overhaul on the system and am now testing new code.I'll post later in this thread, how it goes... Looks promising! 

Good luck in your trades, and have a nice day!


GDPR-24_203122
24 Feb 2016, 12:56

Well the commission is about 100€ actually. I need to have a bot that makes profit from the fluctuation of the market, because it changes all the time. Holding 1 position for ever doesn't get you anywhere and it's difficult to decide when to close it, no matter if it's positive or negative :P


GDPR-24_203122
16 Dec 2015, 08:16

It was actually a strange glitch. Even though the balance-line was straight for 3 years and 70k trades, 98% of those trades were made on june-july 2015. Can't understand why that is, and why that performance isn't transferable to time outside that period. Oh well.


GDPR-24_203122
28 Nov 2015, 12:17

RE:

Spotware said:

Dear Trader,

Please have a look at the following thread: /forum/calgo-support/7314?page=1#6

Thanks for the answer, but changing the timezone +/- 5 hours doesn't  change anything in this case. I tested that. 

My bot uses simply MA as indicator to place trades, and also a little bit of martingaling

Shouldn't the backtesting results with "tickdata" and "m1 bars from server (open prices)" be somewhat similar? In this case the backtest results are totally opposite...

Can you please clarify on this?


GDPR-24_203122
03 Oct 2015, 21:36

Thanks a lot! *thumbsup* 

"Keep it simple"