Topics
Replies

firemyst
16 May 2023, 05:43

That is one thing that is soooooooooooooooooo annoying with the API's Spotware created as they're not consistent across indicators.

I wrote my own multi time frame fractal indicator. Basically, I did it by getting the bars data series time frame I wanted, and then doing the calculations (eg, looking for the midpoint between x number of bars, making sure "x" is an odd number).

 


@firemyst

firemyst
15 May 2023, 13:15

RE: RE:

sifneos4fx said:

This is a prototype of scalping Bot.

Rules:

  • Timeframe: 1 Minute. May also work on 5 minutes 
  • Stochastic K% < 20 and Stochastics K% > Stochastics D%
  • Stochsastic K% should rising
  • RSI should rising
  • Close on Stochsatics K% > 80

Play with parameters ans let me know what you think.

 

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.CentralEuropeanStandardTime, AccessRights = AccessRights.None)]


    public class NewcBot : Robot
    {
        private MovingAverage EMA_Fast;
        private MovingAverage EMA_Slow;
        private StochasticOscillator Stochastics;
        private RelativeStrengthIndex RSI;

        protected override void OnStart()
        {
            EMA_Fast = Indicators.ExponentialMovingAverage(MarketSeries.Close, 50);
            EMA_Slow = Indicators.ExponentialMovingAverage(MarketSeries.Close, 100);
            Stochastics = Indicators.StochasticOscillator(9, 3, 9, MovingAverageType.Exponential);
            RSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }

        protected override void OnTick()
        {
            if ((Server.Time.Hour > 17) && (Server.Time.Hour < 22))
                return;

            if ((NoOrders()) && (RSI.Result.IsRising()) && (EMA_Fast.Result.LastValue > EMA_Slow.Result.LastValue) && (EMA_Fast.Result.IsRising()) && (Stochastics.PercentK.IsRising()) && (Stochastics.PercentK.LastValue < 20) && (Stochastics.PercentK.LastValue > Stochastics.PercentD.LastValue))
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 100000, "Stochastics Scalping", 10, 12);
            }

            if ((Stochastics.PercentK.LastValue > 80))
            {
                foreach (Position pos in Positions)
                {
                    if (pos.SymbolCode == Symbol.Code)
                        ClosePosition(pos);
                }
            }
        }

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

        bool NoOrders()
        {
            foreach (Position pos in Positions)
            {
                if (pos.SymbolCode == Symbol.Code)
                    return false;
            }

            foreach (PendingOrder po in PendingOrders)
            {
                if (po.SymbolCode == Symbol.Code)
                    return false;
            }

            return true;
        }
    }
}

 

Just for kicks, I've been running on one of my VPS's against a demo account across 26 forex pairs M1 timeframe. So far one 0.7pip winner and 6 losses.

 


@firemyst

firemyst
15 May 2023, 11:55

RE:

david.o.levy said:

Are there any apps one can use to capture execution speed using cTrader over a defined period of time (ie 24 hours). 

What do you mean by "execution speed"? How fast orders are executed? Or how fast your custom indicators/bots run? Or something else?

 

The first should be written to the logging tab;

the second one you can put in your C# code statements that capture how fast methods execute and write out the results to the log tab


@firemyst

firemyst
15 May 2023, 11:52

I have multiple bots and bot instances running on Windows Server 2012 that do not through errors whether full access or no access.

So the issue is something in your actual code, which nobody would be able to help with unless you're able to:

1) post your entire code or

2) debug and narrow it down to a certain section of code to post that or

3) post sample code that reproduces the issue


@firemyst

firemyst
15 May 2023, 11:50

RE:

Goulk said:

Hello to all,
I have a question for you, can you create an action that repeats every (X PIP) away ?

Example:

On EURUSD
Every 10 PIPS away from PRICE X, OPEN ONE POSITION.

If possible, I need an example because I am not very practical. 

Thank you for your time
 :D

 

Some sample code to do something every x pips going long:


if (currentPrice >= priceX + (Symbol.PipSize * 10))
{
     //do what you want when you want to be at least 
     //10 pips higher than the last time you entered
}

 


@firemyst

firemyst
14 May 2023, 10:36 ( Updated at: 21 Dec 2023, 09:23 )

RE:

swansonconfidential said:

Very interesting, thank you!!

Have you tried it out? I would be really interested to hear if you saw much improvement from implementing this!

Also, does this mean it only work with Nvidia Graphics cards? Mine is AMD.

Thanks again!

It's a setting in Windows, so try it and see for yourself if it works for AMD and if so, how much of an improvement you see.

Also when running your next back test, right-click on your Windows task bar, select "task manager", and watch the GPU usage if it changes at all:


@firemyst

firemyst
14 May 2023, 10:33

What error messages, if any, do you receive?

Have you tried putting lots of Print statements through your code to see what values are written in the logging tab?

Ex:



Print("LSH {0}, SA {1}", lastSwingHigh, Symbol.Ask);

if (!double.IsNaN(lastSwingHigh) && Symbol.Ask < lastSwingHigh)
            {
                double takeProfitPrice = Math.Max(zigzag.SwingLow.Last(2), zigzag.SwingLow.Last(3));

Print("TPP: {0}, {1}, {2}", takeProfitPrice, zigzag.SwingLow.Last(2), zigzag.SwingLow.Last(3));

                if (double.IsNaN(takeProfitPrice))
                    return;

                double takeProfitPips = (int)((lastSwingHigh - takeProfitPrice) / Symbol.PipSize) * RiskRewardRatio;
                double stopLossPips = (int)((lastSwingHigh - Symbol.Ask) / Symbol.PipSize);

Print("TPP {0}, SLP {1}", takeProfitPips, stopLossPips);

                ExecuteMarketOrder(TradeType.Sell, SymbolName, 1000, "SwingZigZagStrategy", stopLossPips, takeProfitPips);
            }

 


@firemyst

firemyst
14 May 2023, 10:22 ( Updated at: 21 Dec 2023, 09:23 )

If you are running cTrader on a native Windows machine with an Nvidia gfx card, then you can try setting Windows to use the GPU more instead of the CPU in Windows:


@firemyst

firemyst
14 May 2023, 10:19

Try the solution in this thread to clear the local cache in cTrader:

 

Your same issue was happening to me.


@firemyst

firemyst
14 May 2023, 10:16 ( Updated at: 21 Dec 2023, 09:23 )

RE:

dynamites said:

Hello.

It would be great to have immediately an idea of the total amount of a combination of trades. This helps the trader to make a decisions to close or not.

Moreover, a button in the dropdown list like "select all" and "deselect all" would be paramount, especially if you scalp like me.

When you have a long list of open trades, the trade management in cTrader is quite "painful" to say the least...

There are some options available to you in the drop down menu:


@firemyst

firemyst
14 May 2023, 10:13

RE:

mh17462 said:

In which part of the website can I see a list of all the brokers who are working with you?

 

Well, for starters, if you really need this information, you could have:

1) looked on Spotware's website for a list of brokers:

2) used Google. "ctrader brokers list". Returns numerous pages. Here's one:

 

That took less than 5 minutes to do and should give you enough to go on.

 


@firemyst

firemyst
11 May 2023, 11:13

RE:

ncel01 said:

firemyst,

I can confirm the same discrepancy between cTrader desktop and cTrader mobile.

:

:

After all, as desired, you're able to sort all the trades in history, right?

 

 

Either way, it's a bug in how it operates, and I would hope @Spotware would want to fix it since their product is not working as expected.

 

 


@firemyst

firemyst
11 May 2023, 05:08

You can use it to gauge the strength/weakness of the indicator's trend.

Note that the angle can change depending on the zoom level of the chart


@firemyst

firemyst
11 May 2023, 05:05

What's the problem? Eg, why do you think it doesn't work?

Also, are you aware cTrader has HA candles built in, so you don't have to calculate them yourself -- just pass in the market data by choosing the appropriate timeframe. That is, Timeframe.HeinkinDay, etc.


@firemyst

firemyst
11 May 2023, 03:24 ( Updated at: 21 Dec 2023, 09:23 )

RE:

ncel01 said:

Hi firemyst,

Yes, it still can make sense.

As far as I can see, there is no mention to ascending/descending in cTrader desktop. This means that, most likely, what you consider to be a descending order has been defined as an ascending order.

This makes sense if the criteria is, for instance, the elapsed time between the closing and current times.

Ascending / Descending is right here on the column headings in cTrader desktop. Click on any column heading and it shows you how it's sorted

click on the heading again to reverse the sorting:

 

It's practically a universal standard that when you want date/times in descending order, it means you go from the most recent to the least recent, as showing in cTrader desktop:

 

And in any SQL database when you say, "SELECT * FROM myDatabase ORDER BY aDateTimeColumn DESC" any database will return the values sorted by "aDateTimeColumn" with the most recent date/timestamp first and continuing until the record with the oldest date/timestamp is last in the results.

So seeing how cTrader mobile is working, I suspect when @Spotware applies the filter, they mixed up ASC vs DESC in their data query.


@firemyst

firemyst
11 May 2023, 02:43 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE:

ncel01 said:

Hi firemyst,

Did you try the filter (3 dots at the top right corner)?

 

I did. And actually, because of your suggestion, I went back and scrutinized it. It looks like there's a BUG between the cTrader desktop sorting and the cTrader mobile sorting, which is why I couldn't get it to work.

Follow the screen captures from my demo account:

Here is cTrader Desktop sorted, as you can see, by closing time in DESCENDING ORDER. This is what I expected to see in cTrader mobile as well:

Now when I view my "history" on cTrader mobile sorted closing time in DESCENDING ORDER, you'll see completely different results:

 

Now if I set the cTrader Mobile history filter to sort by closing time ASCENDING, look at the results -- they are the same as cTrader desktop when sorted in DESCENDING order:

 

See the difference? Does it work like this for anyone else?

To me, this is a bug. Sorting by Closing Time DESCENDING should show the exact same results in both cTrader Desktop and Mobile.

@Spotware?

 


@firemyst

firemyst
09 May 2023, 12:30

You are indeed :-)

To get the values from the indicator, you need to call the indicator's "calculate" method. This can done by either of the following:

1) Call the Calculate method directly and pass in the index number

2) call the ".Last(x)" method on your indicator automatically calls the "Calculate" method to retrieve the values.

and you need to call the Calculate method before you use any of the resulting values.

If you don't do either, the indicator doesn't run (it's the 'lazy loading') and sits idle.


@firemyst

firemyst
09 May 2023, 03:06

Just remove the "OUTPUT" directive and keep it as a "public" property.

 

For example, instead of this:

 [Output("Referenced SMA Output")]
 public IndicatorDataSeries refSMA { get; set; }

 

Make it this. Note that when doing it this way you will have to do a CreateDataSeries() in the Initialize method:

public IndicatorDataSeries refSMA { get; set; }

@firemyst

firemyst
09 May 2023, 03:03

If you need a work around, you can write your own indicator that combines the two into a single indicator area below the chart.

 

Also, you might want to do a search in the indicator archives to see if someone's already created one:

 


@firemyst

firemyst
07 May 2023, 14:22

RE: RE: RE:

meeting.chegini said:

firemyst said:

meeting.chegini said:

Hello
How do I know the name of the indicator in the IndicatorAreas?

For example, What is the name of the Chart.IndicatorAreas[0] indicator?

Try something like this:

Chart.IndicatorAreas[0].Objects[0].Name

Because each indicator area can have more than 1 object in it, you'll have to loop through all the objects to get all their names.

I don't want this!!

I want a code that gives me the name of the oscillator

 

I just gave you the general code above on what you have to do.

It's up to you to implement depending on the rest of your code.

I'm not going to write everything for you.

 


@firemyst