Topics
Replies
Mr4x
11 Nov 2023, 07:42
RE: Calculate profit in account dollars instead of pips
PanagiotisCharalampous said:
Hi there
Try this
if (Positions.Where(x => x.SymbolName == SymbolName && x.Label == ThiscBotLabel).Average(x => x.NetProfit) >= AmountInProfit)
Thank you for your quick reply Panagiotis. Unfortunately when I put that in, all positions close at random dollar figures. For example if I put in “2” as a whole number - then positions are closed anywhere from $2 to $22 in profit in my base currency.
Is there any function to normalise and make sure that all positions are closed at (or close enough to) the dollar figure that is put as the “AmountInProfit”?
Thanks
@Mr4x
Mr4x
25 Apr 2022, 17:38
RE:
Copying the name of my strategy in this forum? Real greasy bro, create your own strategy name.
The actual Conservative Investment strategy can be found here:
https://ct.icmarkets.com/copy/strategy/39883
Myfxwork said:
The EA does not uses Averaging or Grid. It only enters a trade with stop loss and take profit for each trade! The average yield is 100-200% in a year. Copying this strategy is secure.
https://ct.icmarkets.com/copy/strategy/41567
Recommended Broker:
Raw spread account of Icmarket Broker with leverage 1:500More Details:
www.myfxwork.com
@Mr4x
Mr4x
02 Apr 2022, 02:32
RE:
amusleh said:
Hi,
You should never use DateTime.Now or DateTimeOffset.Now in backtest environment, because those two are .NET BCL APIs that uses your system time.
Instead you should use Server.Time and Server.TimeInUtc which will give you the current time of the server is live mode and the current time in backtest environment.
Thank you for your feedback. For this I do want the bot to execute according to my local system time
@Mr4x
Mr4x
02 Apr 2022, 02:32
RE: RE:
Shares4UsDevelopment said:
if ((Bars[index].OpenTime.Hour == HourOpen) && (Bars[index].OpenTime..Minute == MinuteOpen) && (Bars[index].OpenTime.Second >= 0))
DateTime.Now is the current time
Thank you for your prompt reply Shares. I have tried substituting with the following code:
if (Positions.Count(x => x.Label == ThiscBotLabel) == 0)
{
if ((Bars[1].OpenTime.Hour == HourOpen) && (Bars[1].OpenTime.Minute == MinuteOpen) && (Bars[1].OpenTime.Second >= 0))
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, ThiscBotLabel, null, InitialTakeProfit);
LastBuyTradeTime = MarketSeries.OpenTime.Last(0);
}
}
And I am still not getting any results in the backtest... Do you have any other suggestions?
@Mr4x
Mr4x
13 Dec 2021, 13:11
New Link up and running
Old strategy closed due to lack of interest, but I've restarted it now. Same account, new link:
https://ct.icmarkets.com/copy/strategy/39883
@Mr4x
Mr4x
25 Nov 2021, 10:36
RE: RE:
Great performance so far mate... I notice your strategy involves some sort of mean reversion... Do you keep an eye on the news and avoid trading during days like when we had the meltdown in February / March 2020?
Also, if you wanted to consider a strategy that doesn't need so much capital invested, you could try applying this to the US500 since its correlation with US30 is almost 100% most of the time and you can trade much smaller lot sizes :)
@Mr4x
Mr4x
21 Oct 2021, 14:25
( Updated at: 13 Dec 2021, 13:11 )
I'm Back!
Hi Everybody,
I closed down my strategy back in April due to personal circumstances which meant I could not be at a computer to monitor the trades.
I have now restarted the strategy and tweaked it a little, using the same account as I was using earlier in the year to prove I did not blow up the account.
New link to my strategy is below :)
https://ct.icmarkets.com/copy/strategy/39883
Sorry I do not have a telegram group
@Mr4x
Mr4x
21 Oct 2021, 14:24
( Updated at: 13 Dec 2021, 13:13 )
I'm back!
Hi Everybody,
I closed down my strategy back in April due to personal circumstances which meant I could not be at a computer to monitor the trades.
I have now restarted the strategy and tweaked it a little, using the same account as I was using earlier in the year to prove I did not blow up the account.
New link to my strategy is below :)
https://ct.icmarkets.com/copy/strategy/39883
@Mr4x
Mr4x
10 Feb 2021, 13:20
RE:
TheMC said:
Hi, I would like to copy you.
What does it mean that it is set at 200%? Double the size compared to what was done on myfxbook (so double the roi and any dd?). Where do you recommend putting the SL? 10% is enough?
Hi mate thanks for asking,
The performance should be roughly double as well as the DD yes. Although trades can vary because they are started and stopped at the same time as the master MT4 account, but quote prices may be slightly different between the platforms so you may end up with a bit more or a bit less each trade, also ctrader commissions are higher than MT4...
The max DD of the MT4 strategy so far is 12% so with mine it could potentially reach 24%, so I would really advise against setting SL anything less than that.
For reference, Relax and Fibo23 often have DD's well above 40% and they are still going.
@Mr4x
Mr4x
05 Feb 2021, 03:23
RE: RE: Conservative Investment
long.phamdinhhoang said:
Mr4x said:
You could try my strategy, low drawdown and 100% p.a with 3 year live backtested.
https://ct.icmarkets.com/copy/strategy/14462
The other popular ones would be Relax and Fibo23 - both are tracking at about 20% per month but both follow almost identical strategies using EURUSD whereas mine uses GBPCAD, so you could put a little in each for diversification of assets in case one or the other goes bust one day :)
Hi Mr4x,
I think you put the wrong link (it's relax1 strategy i think).
Like you, I also developed a strategy (using a bot) that focus on minimizing equity/balance drawdown while still generates a steady return (15%-25%) (2 years backtested and 5 months forwardtested)
In fact, my strategy is a lot like Relax strategy, the only thing that is different is I trade smaller lots and take profit earlier.
If you can't copy Relax then I hope you spend some time to look at my strategy. You can check out my strategy at: https://ct.icmarkets.com/copy/strategy/21154.
Have a great day everyone and happy trading.
Kind regards,
Long Pham
Hi Long Pham,
Thank you so much for spotting that! Haha I must have copied the wrong link whilst looking at his strat. I have edited my post now.
@Mr4x
Mr4x
04 Feb 2021, 13:41
( Updated at: 05 Feb 2021, 03:22 )
Conservative Investment
You could try my strategy, low drawdown and 100% p.a with 3 year live backtested.
https://ct.icmarkets.com/copy/strategy/17195
The other popular ones would be Relax and Fibo23 - both are tracking at about 20% per month but both follow almost identical strategies using EURUSD whereas mine uses GBPCAD, so you could put a little in each for diversification of assets in case one or the other goes bust one day :)
@Mr4x
Mr4x
28 Jan 2020, 16:09
3.7 Final Version?
Hi Guys,
This is great work. You have literally saved me months of forward testing multi-symbol strategies on demo accounts thanks to multi-symbol back-tests.
Quick question - any idea when 3.7 will no longer be in Beta production and be ready for brokers to use? The Spotware cTrader demo lacks a few symbols that my broker has which are key to my strategies so I'll be very keen to get multi-symbol back-testing working on my broker...
Regards,
Mr4x
@Mr4x
Mr4x
05 Jan 2020, 04:50
Faster way to close all positions?
Hi,
Is there a faster way to close all positions than this code? When executing this against multiple positions that are open, it seems to close them one by one with half a second apart. When scalping this can turn a winning trade into a losing trade from the time lag, as I experienced the other day.
When you double click "Close All Positions" within cTrader it does actually close them all at the exact same time (or very close to), not one by one. Is there anyway cAlgo can do this? If not, can you write some code into a future version of cTrader which basically mimics the "Close All Positions" button?
Regards,
Mr4x
@Mr4x
Mr4x
25 Nov 2019, 17:03
Panagiotis Charalampous said:
Hi Mr4x,
See below an example of how to check for Net Profit on sell positions only
if (Account.Equity >= Account.Balance + Positions.Where(x => x.TradeType == TradeType.Sell).Sum(p => p.NetProfit)) { foreach (var position in Positions) { ClosePosition(position); } }
Best Regards,
Panagiotis
Hi Panagiotis,
Thank you once again for that speedy reply. I just need one more piece to the puzzle and I think I have solved it. In the above code could you please give me an example of what it would look like if I wanted to close all sell positions if Net Profit of all sell positions was 150? I'm trying to see where in the code I would put that but can't for the life of me figure it out.
Many thanks,
Mr4x
@Mr4x
Mr4x
23 Nov 2019, 06:41
Great Concept, a few bugs
Hi tgjobscv,
Your code works a treat when selling XAUUSD over the past 3 months of this year, however if you try to do a back-test on a $10,000 account over the past year (22-11-18 to 22-11-19) you do get 100% draw-down during December 2018. Might need to tweak the code a bit?
Anyway the feature that is broken is the ability to use this as "buy only". If you set "buy" to yes and "sell" to no then try and back-test, the cbot still places sell side orders. I'm looking at running a hedge-type situation using a buy with XAUEUR side-by-side with sell XAUUSD, so if you could fix the cbot and then maybe play around with that idea of mine too and see what you think.
Cheers,
Mr4x
@Mr4x
Mr4x
13 Apr 2019, 06:34
RE: RE:
thegreat.super said:
Mr4x said:
Hi Panagiotis,
Thank you for your terrific work you have done on here.
The original code that thegreat.super has posted on here worked a treat with your modifications - I'm not sure why it is not working for him?
Anyway I would like to make a modification to this, and I hope it is something simple you can help me with, even if you could just tell me what the simple line of code is I'm sure I can figure out where to put it.
Basically all I want to know is how can you prevent it from executing a trade if the spread exceeds a certain number, for example 2 pips? I still would want it to continue placing trades once the spread falls below that number. It is basically to prevent it from executing a trade during a major news event like non-farm payrolls.
Many thanks again
Hi Mr4x,
The ped_scalpingLimit controls the spread and commission.......20 means the spread + commission must be ;less that 2 pips to work...try the settings and see. Also can you send me the working code because mine still wth lot of errors. Thanks
This one that was pasted worked for me:
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 ashi : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Parameter("ProfitTarget", DefaultValue = 300)] public double ProfitTarget { get; set; } [Parameter("Volume", DefaultValue = 10000)] public int Volume { get; set; } public double balance; public double lastTradePrice; public TradeResult lastposition; protected override void OnStart() { // Get the initial balance balance = Account.Balance; Print(balance); // Start hedge grid lastposition = ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "buy", 0, 2); ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "buy", 0, 2); } protected override void OnTick() { // Open more trades if the price moved 5 pips if (lastposition != null && lastposition.Position.Pips > 5) { lastposition = ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "buy", 0, 2); } if (lastposition != null && lastposition.Position.Pips < -5) { lastposition = ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "sell", 0, 2); } // Check if equity is in profit then shut down the grid cycle if (Account.Equity >= balance + 2) { foreach (var position in Positions) { ClosePosition(position); } balance = Account.Balance; Print(balance); // Start hedge grid ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "buy", 0, 2); ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "sell", 0, 2); } } protected override void OnStop() { // Put your deinitialization logic here } } }
However I used a slightly modified version, whereby I took out the part about adding more positions, and only having 2 open positions at a time, because I'm using it for a different purpose. Thus mine looks more like this:
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 Tester : Robot { [Parameter("ProfitTarget", DefaultValue = 300)] public double ProfitTarget { get; set; } [Parameter("Volume", DefaultValue = 10000)] public int Volume { get; set; } public double balance; protected override void OnStart() { // Get the initial balance balance = Account.Balance; Print(balance); } protected override void OnTick() { // Check if equity is in profit then shut down the grid cycle if (Account.Equity >= balance + ProfitTarget) { foreach (var position in Positions) { ClosePosition(position); } balance = Account.Balance; Print(balance); // Start hedge grid if (Positions.Count < 2) { ExecuteMarketOrder(TradeType.Buy, symbol, Volume, "buy", 0, 0); ExecuteMarketOrder(TradeType.Sell, symbol, Volume, "sell", 0, 0); } } } protected override void OnStop() { // Put your deinitialization logic here } } }
@Mr4x
Mr4x
12 Apr 2019, 00:35
Hi Panagiotis,
Thank you for your terrific work you have done on here.
The original code that thegreat.super has posted on here worked a treat with your modifications - I'm not sure why it is not working for him?
Anyway I would like to make a modification to this, and I hope it is something simple you can help me with, even if you could just tell me what the simple line of code is I'm sure I can figure out where to put it.
Basically all I want to know is how can you prevent it from executing a trade if the spread exceeds a certain number, for example 2 pips? I still would want it to continue placing trades once the spread falls below that number. It is basically to prevent it from executing a trade during a major news event like non-farm payrolls.
Many thanks again
@Mr4x
Mr4x
12 Nov 2023, 07:04
RE: Calculate profit in account dollars instead of pips
PanagiotisCharalampous said:
Thank you again for your reply. I tried that exact code but I get the following build failed error:
Error CS0029: Cannot implicitly convert type ‘System.Collections.Generic.IEnumerable<cAlgo.API.Position>’ to 'bool'
@Mr4x