Topics
Replies
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
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
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
13 May 2023, 11:08
RE: RE:
Unfortunately not.
@davidp13