Topics
Replies

firemyst
24 Jul 2023, 23:45

It would help if you actually posted a video or screen capture showing your issue since nobody else seems to be encountering it


@firemyst

firemyst
21 Jul 2023, 00:07

Or if not a simple checkbox, how about something like in CSS where users can specify the Z-index so this way they can stack the indicators as they would like?


@firemyst

firemyst
21 Jul 2023, 00:04

RE: RE:

jamesgoodman said: 

firemyst said:

Did you add your Rate of Change as a "reference" to your bot?

No I have created the RateOfChange in the indicator class and then used the Indicators.GetIndicators function in main bot. Are you saying I need to create it in an external library?

 

 

Read this:

https://clickalgo.com/ctrader-assembly-reference

 


@firemyst

firemyst
19 Jul 2023, 14:41

Adding to what PanagiotisChar said, example of getting the H1 timeframe:

Bars myBars = MarketData.GetBars(TimeFrame.Hour);


@firemyst

firemyst
18 Jul 2023, 12:53

Your suggestion would carry more weight and be able to be tracked if you posted it in the correct forum:

 


@firemyst

firemyst
18 Jul 2023, 11:02

RE:

Spotware said:

Hi firemyst,

Can you please install this hotfix and let us know if it resolves the problem?

Best regards,

cTrader Team

 

Sure. So far I've only had 1 crash today. I'll try installing it in about 12 hours from now (bots and other things running) and see how we go from there.

Thank you.


@firemyst

firemyst
17 Jul 2023, 09:47

Did you add your Rate of Change as a "reference" to your bot?


@firemyst

firemyst
14 Jul 2023, 03:29

RE:

ncel01 said:

firemyst,

Not really. That's simply the error description.

What I want is to access to the trade operation ExecuteMarketOrderAsync() parameters, in this case to the label.
The goal is to know, exactly, which operation has failed: "Position #1" vs "Position #2".

 

Then you might want to try a brute force way:

 

//written off the top of my head, so may not work exactly as is
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class MarketOrderTest : Robot
    {

    //we'll add the labels of the orders we place to this object:
	Dictionary<int, string> d = new Dictionary<int, string>();
    //keep track of each async trade
	bool trade1Finished = false;
	bool trade2Finished = false;

        protected override void OnStart()
        {
                                string label1 = "Position #1";
                                string label2 = "Position #2";
                                d.Add(1, label1);
                                d.Add(2, label2);
                                trade1Finished = false;
                                trade2Finished = false;
                                ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, d[1], (TradeResult r) =>
                                {
                                    if (r.IsSuccessful)
                                    {
                                        //remove from dictionary object as we know it completed
                                        if (r.Position.Label == label1)
                                            d.Remove(1);
                                    }
                                    trade1Finished = true; //done tracking this trade
                                });
                                ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, d[2], (TradeResult r) =>
                                {
                                    if (r.IsSuccessful)
                                    {
                                        //remove from dictionary object as we know it completed
                                        if (r.Position.Label == label2)
                                            d.Remove(2);
                                    }
                                    trade2Finished = true; //done. This trade finished
                                });
        }

        protected override void OnTick()
        {
        //check when both trades are done.
        //can also alter so that you check each trade individually
		if (trade1Finished && trade2Finished)
		{
                                if (d.ContainsKey(1))
                                {
                                    //error occurred with this order since key still exists
                                }
                                if (d.ContainsKey(2))
                                {
                                    //error occurred with this order
                                }
		}

        }
    }
}

 


@firemyst

firemyst
13 Jul 2023, 11:06

RE: close part of position

aloin.eldar said:

Hi there guys,

Sorry for approaching in another issue, because i can't get an answer anywhere else.

Let's say i open a position of 0.5 lot, and i want to close 0.3 (meaning - leave 0.2)

Why does the platform closes the position entirely and open up a new one, of 0.2 lot, at the time of the previous close?

Is this right?

BR

Maybe if on the other threadds you started you post screen captures showing examples as evidence of what's happening, you'd get some responses.


@firemyst

firemyst
13 Jul 2023, 11:05

And the accounts keep disconnecting and reconnecting today. It's like the demo server feed can't keep it up.


@firemyst

firemyst
13 Jul 2023, 03:43

//Does this get what you want?

if (!obj.IsSuccessful)
{
    if (obj.Error.HasValue)
    {
        Print("Error! : {0}", obj.Error.Value.ToString();
    }
}

 


@firemyst

firemyst
11 Jul 2023, 14:58

You'll need to call the OnBar method yourself, so you can then execute code both before and/or after it.

 


//Example code

//class variable. Set to zero in the OnStart method so it's 0 every time you start your bot
int _previousIndex;
int _currentIndex;

//in the "OnTick" Method
protected override void OnTick()
{
    //do whatever you need to do in OnTick first here

    _currentIndex = _marketSeries.OpenTimes.GetIndexByTime(_marketSeries.OpenTimes.LastValue);

    //Call the OnBar method yourself. Just make your own. 
    if (_currentIndex != _previousIndex)
    {
        //when currentIndex isn't equal to previous index, we know a new bar has opened
        //so call your own OnBar method:
        OnBarForBot();
        _previousIndex = _currentIndex;
    }

    //Now do whatever you have to after you called your OnBar method
}

private void OnBarForBot()
{
    //do whatever you want to on each new bar
}

//Don't have anything in the built in method. 
protected override void OnBar()
{
}

 


@firemyst

firemyst
11 Jul 2023, 14:51

@ClickAlgo doesn't support their software unless it's a bug or you've paid for it.

I wonder why they can't help?

 


@firemyst

firemyst
08 Jul 2023, 08:06

RE:

ctid1531384 said:

Yes aware of them. And the ones I asked about? Just gone?

These?

 

 


@firemyst

firemyst
07 Jul 2023, 03:41

As a follow on to the above from @lisandronahuelhillebrand , see this page for more information about Opposite Side of Trade:

 


@firemyst

firemyst
07 Jul 2023, 03:30

 


@firemyst

firemyst
07 Jul 2023, 03:29

Your post makes no sense


@firemyst

firemyst
07 Jul 2023, 03:29

Good place to start:

 


@firemyst

firemyst
07 Jul 2023, 03:24

Why not post the code you have so people can correct it?

 

In a nutshell:

1) set your time zone in your indicator if you choose:

    [Indicator(AccessRights = AccessRights.None, TimeZone = TimeZones.AtlanticStandardTime)]

2) get your time Server.Time or if you want your local computer's DateTime.Now

3) compare that the hour of the time you got is >= 8 && <= 9

4) if 3 is true, Chart.DrawHorizontalLine on whatever value you want at 8 and 9am prices. Depending on the chart you're using, you may need to get tick data as opposed to the chart's time frame (eg, if you use something like Range or Renko, you can't depend on a bar's time as a new bar may not open/close on the exact hours)


@firemyst

firemyst
07 Jul 2023, 03:15

//just provide the source to the dataseries parameter when creating the RSI in your code:

RelativeStrengthIndex _rsi = Indicators.RelativeStrengthIndex([the data series of the symbol/timeframe you want the rsi to act upon], Periods);

 


@firemyst