Topics
30 Jun 2020, 13:27
 1086
 4
05 Sep 2017, 21:33
 1930
 2
09 Jul 2017, 14:37
 2430
 4
09 Jul 2017, 14:14
 2681
 3
04 Jan 2017, 19:20
 1510
 2
30 Dec 2016, 10:17
 2454
 2
12 Dec 2016, 09:15
 1877
 1
22 Oct 2016, 07:31
 2
 807
 2
17 Oct 2016, 00:14
 4769
 8
10 Oct 2016, 11:51
 3427
 5
Replies

davidp13
13 May 2023, 11:08

RE: RE:

Unfortunately not. 


@davidp13

davidp13
14 Jul 2020, 13:17

Hi. Is it possible to set stop/profit at price yet?


@davidp13

davidp13
30 Jun 2020, 13:58

RE:

I worked it out. I used Server.Time.Day instead of DateTime.Today.Day and it worked. 

 

 


@davidp13

davidp13
18 Jul 2017, 10:00

RE:

I have a system that generates buy/sell signals outside of cTrader, however I open the trades on cTrader. The system is designed on US indexes, but not the 24hr contracts, but I trade the 24hr contract through cTrader. The trades open at US market OPEN and close out when the signal is true at US market CLOSE. I have built a cbot that i simply switch on/off with the time and volume specified based on  my signals, but I want to automate this. My issue seem the time I want to open the trades. I'm not finding a way to do it. I cannot simply create orders cause I cannot specify open/close time as an example.

I'm open to suggestions pls.

Thanks

 

Spotware said:

Hi davidp13,

Thanks for your question. No this is not possible to start and stop a cBot using Connect API. Could you tell us a bit more on what you are trying to achieve, in case we can propose an alternative solution?

Best Regards,

cTrader Team

 


@davidp13

davidp13
22 Jan 2017, 19:33

I figured that I wll use the Robot name, equal that to the comment of the trade and then filter that with a unique lable. Not elegant at all, but what can I do...


@davidp13

davidp13
05 Jan 2017, 21:53

Something is wrong with the current version. It consumes memory and looses connectivity constantly. What is wrong?

Admin please get back to us ASAP.


@davidp13

davidp13
05 Jan 2017, 21:52

there is a connection issue with the new version!!!

admin what is going on? urgently get back to us all pls!!

who else is having connection issues?


@davidp13

davidp13
04 Jan 2017, 21:48

something crappy is going on with the connection today!!!


@davidp13

davidp13
13 Dec 2016, 07:14

RE:

Thanks cyfer. So if I put this code in Int. will it store the value until it changes? 

Again thank you for helping out.

cyfer said:

Concept :

Test the Candle that Closed for the Close price : [index-1]

Test the Previous Value of the EMA  : EMA15.Result[index-1]

Set a Bool Switch For CandleAboveEma & CandleBelowEMA 

Code :

//Init
private bool CandleAboveEma ,CandleBelowEMA ;

Calculate()
{
   if(Marketseries.Close[index-1] > EMA15.Resulst[Index-1])
     {
       CandleAboveEma = True ;
       CandleBelowEMA  = False ;
     }
   else if(Marketseries.Close[index-1] < EMA15.Resulst[Index-1])
    {
      CandleAboveEma = True ;
      CandleBelowEMA  = False ;
    }
}

sure you can make only one Bool and test it ,but his will make sense if you're developing a big Indicator or Robot.

you must test the Previous EMA Value & Previous Candle . .. not the current values . 

 

 


@davidp13

davidp13
02 Dec 2016, 10:56

RE:

Hi. How will you go about calculating the AvgWinning or AvgLosing trade?

cjdduarte said:

// MultiCharts Custom Criteria: Pessimistic Return on Margin (PROM) by Robert Pardo

// Change the value below to your account size
var AccountSize = 10000;

/* The code below can be left untouched  */

// check for errors / wrong values
if (AccountSize < 1 || StrategyPerformance.WinningTrades == 0 ||
    StrategyPerformance.LosingTrades == 0) {
    return 0;
}

var sqrtWins = Math.sqrt(StrategyPerformance.WinningTrades);
var sqrtLosses = Math.sqrt(StrategyPerformance.LosingTrades);

return ( ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.WinningTrades - sqrtWins) ) -
    ( -StrategyPerformance.AvgLosingTrade * (StrategyPerformance.LosingTrades + sqrtLosses) )) /
    AccountSize) * 100;

 

 


@davidp13

davidp13
29 Nov 2016, 22:07

RE:

But what gets me the most is that when I change the code from ModifyPosition(position, newStopLoss, null); to ModifyPosition(position, newStopLoss,  position.TakeProfit); then it seems to function fine. WHY IS THAT? It really really makes no sense. Is their something wrong with the backtest engin?

Spotware said:

We concur with tmc that this most likely caused by negative spread in the historical data. We suggest that you try to test on m1 trendbar data instead of tick data and let us know if the issue exists or not. 

Many thanks, 

 


@davidp13

davidp13
29 Nov 2016, 21:22

RE:

I have tested it on Tick, 1m and 5m bars...sames story. As soon as I use Symbol.Bid (for Long tracking) or Symbol.Ask (for Short tracking) the backtesting engin does not work like it should. As an example, if I'm long and I want to trail my position there should be no reason why I cannot subtract a certain number form the last Bid price to move my stop closer. But, your backtest engin does not seem to be able to compute this effectively and thus creates not necesserily losing trades, but they stay open longer than what they should have and thus causing the system to go out of sequence.

I have furthermore printed some numbers and have also found that the backtest allows that a position (lets say long) can have a bigger SL than what the cirrent Bid price is. HOW IS THIS POSSIBLE???

Here is an extract from the backtest:

Bid - Bid price; CSL - Current StopLoss;

02/01/2015 15:02:00.000    Pos ID 2, Label L V3 USDJPY, Bid 120.482, CSL 120.519214285714

 

 

Spotware said:

We concur with tmc that this most likely caused by negative spread in the historical data. We suggest that you try to test on m1 trendbar data instead of tick data and let us know if the issue exists or not. 

Many thanks, 

 


@davidp13

davidp13
28 Nov 2016, 11:42

Spotware pls will you comment on why this issue occurs when that field is populated with null value. This is a huge issue for me and need and answer on this pls. Thanks


@davidp13

davidp13
27 Nov 2016, 20:08

Hi. I also picked up something funny. Could not figure out if it was -ve spread. I posted what I found here - /forum/calgo-support/10976

For some reason using null in the TakeProfit filed while calling ModifyPosition caused issues. Does not make sense to me.


@davidp13

davidp13
27 Nov 2016, 19:07

tmc - thanks for getting back to me, however i'm not sure that is what caused it.

I have a piece of code that supposedly tracks any open position - like a trailing stop. I use the ModifyPosition call, but i then set the TakeProfit value to null . I changed the code to rather us position.TakeProfit and it stopped it, but the results are not as good as they were before. still profitable, but not pretty. 

Here is the code. Anyone have a clue why this would cause such a problem? Strangely enough I have been running this in Live and Demo for a couple of months with good results.

 

var beATR = atr.Result.LastValue * ATRMultiP;

if (position.TradeType == TradeType.Buy && position.Label == label)
                {
                    if (position.Pips >= TrailTrigger)
                    {
                        var newStopLoss = Symbol.Bid - beATR;
                        if (position.StopLoss < newStopLoss - Trail)
                            ModifyPosition(position, newStopLoss, null);
                    }
                }


@davidp13

davidp13
26 Nov 2016, 10:18

thank you


@davidp13

davidp13
23 Nov 2016, 15:09

the easiest would be to test if a position is open or not and if not then execture the order.

Somthing like:

if position == null

executemarketorder...


@davidp13

davidp13
26 Oct 2016, 16:37

Thanks. I'm not sure this is going to help me.

Maybe let me ask this - how do I store the Position.ID to a variable once a position is opened in order for me to use it with break even code as an example?


@davidp13

davidp13
15 Oct 2016, 19:35

RE:

I got it - use Symbol.TickSize and not pipsize

lucian said:

You can try  divided by  Symbol.PipSize.

 


@davidp13

davidp13
10 Oct 2016, 14:26

Tried. If you do that you still get 25. 0.25/0.01 = 25. 


@davidp13