Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Curious as to whether anyone has been able to code a profitable trading bot specifically for CL or MCL futures? I have been working to accomplish this, and wanted to see if anyone else had a successful bot they were willing to share. Appreciate it!
The following 2 users say Thank You to gftrader for this post:
Are you willing to share a percent of your profits from this bot ?
What's the number ? 50%, 80%, what ?
Coding and testing these "BOTS" are hugely time-consuming.
The following user says Thank You to syswizard for this post:
Free, but many people do not like the only roughly 12 trades per year... Flat periods are just sitting on your hands...
I should mention all performance since Jan 1, 2022 is LIVE real time performance (strategy was developed in 2021).
Crazy simple stupid...
input: daysback(65),stopl(3000),fac(1.5);
if ADX(14)>10 and close-close[daysback] crosses above 0 then buy next bar at market;
if ADX(14)>10 and close-close[daysback] crosses below 0 then sellshort next bar at market;
SetStopPosition;
SetStopLoss(stopl);
SetProfitTarget(stopl*fac);
The following 7 users say Thank You to kevinkdog for this post:
But feel free to share your trailing stop code if you want (I hope it is not setdollartrailing or setperecenttrailing).
Ok Kevin, here you go. This signal features a retracement percentage that can be adjusted.
Also features a fixed stop as well as a volatility stop. Note: both can be active at the same time,
but the fixed stop takes precedent.
Inputs:
iBarsSince (4) // min # of bars in the trade before the stop logic is triggered
, iProfitTicksMin (10)
, iPercentRetrace (25)
, iFixedStopTicks (-20) // set to zero to disable
, iVolaTilLength (10) // Set to zero to disable
, iDebug(false)
, iDebugDate("") // Format=2022/12/01
;
Variables:
vProfitPts(0)
, vProfitTicks(0)
, vProfitTicksMax(0)
, vProfitPctFromMax(0)
, vMP(0)
, vEP(0)
, vBSE(0)
, vVolaTilTicks (0)
, vRetVal(-1)
, vTicksPerPoint (1/TickSize) // ticksize for ES = 0.25
, vDebugFile("D:\MultichartsData\debug\szylTrailTicksPctSig.txt")
;
vMP = MarketPosition; vEP = EntryPrice; vBSE = BarsSinceEntry;
vProfitPts = sign(vMP)*(Close-vEP);
vProfitTicks = Iff(vProfitPts <> 0 , Round(vTicksPerPoint * vProfitPts,0), 0) ;
vVolaTilTicks = Round(_szHIHILOLO(iVolaTilLength) * vTicksPerPoint,0);
If vMP <> vMP[1] Then // change in position
vProfitTicksMax = vProfitTicks // initialize the max profit
Else if vMP <> 0 Then // recompute max profit
vProfitTicksMax = Iff(vProfitTicks > VProfitTicksMax, vProfitTicks, vProfitTicksMax)
;
if vProfitTicksMax <> 0 Then // Compute the retracement percentage
vProfitPctFromMax = 100 * ((vProfitTicksMax - vProfitTicks)/vProfitTicksMax)
Else vProfitPctFromMax = 0;
if iDebug and (_szFormatDate()= iDebugDate or iDebugDate = "") then
Print(File(vDebugFile),"debug for MP=",vMP:2:0," vProfitTicks=",vProfitTicks,
" vProfitTicksMax=",vProfitTicksMax," ","vProfitPctFromMax=",vProfitPctFromMax," ",iDebugDate," ",NumToStr(Time,0));
// Profit retracement exit
If vProfitPctFromMax > iPercentRetrace and vProfitTicksMax > iProfitTicksMin and vBSE > iBarsSince then
Begin
if vMP > 0 Then
Sell ("TrlPctXL") CurrentContracts Contracts This Bar at Close
Else If vMP < 0 Then
BuyToCover ("TrlPctXS") CurrentContracts Contracts This Bar at Close;
End;
// Fixed stop loss
if vProfitTicks < iFixedStopTicks and iFixedStopTicks <> 0 Then
Begin
if vMP > 0 Then
Sell ("FixedStopXL") CurrentContracts Contracts This Bar at Close
Else If vMP < 0 Then
BuyToCover ("FixedStopXS") CurrentContracts Contracts This Bar at Close;
End;
// Volatility stop loss
if vProfitTicks < -vVolaTilTicks and iVolaTilLength <> 0 Then
Begin
if vMP > 0 Then
Sell ("VolaTilStopXL") CurrentContracts Contracts This Bar at Close
Else If vMP < 0 Then
BuyToCover ("VolaTilStopXS") CurrentContracts Contracts This Bar at Close;
End;
Thanks for sharing. How many of those inputs did you optimize to get a better curve?
I'm curious, for the strategy I gave, what did you see that made you want to make it better?
I should also mention your trailing stop code, with "sell/buytocover this bar on close" will NEVER work in real time with daily bars. Backtest is fine, but not live trading. Not sure if you realized this.
Just FYI, I did not do optimization of this, all values were a "best guess." Initial data was 02/2010 to 06/2019.
From June 2019- Jan 2022 (2.5 years was out of sample).
Jan 2022- present is all live, real time performance (as calculated by backtest engine).
The following 3 users say Thank You to kevinkdog for this post:
Thanks for sharing. How many of those inputs did you optimize to get a better curve?
No optimization done. Testing done on a 600 tick chart.
kevinkdog
I'm curious, for the strategy I gave, what did you see that made you want to make it better?
Which strategy ?
kevinkdog
I should also mention your trailing stop code, with "sell/buytocover this bar on close" will NEVER work in real time with daily bars. Backtest is fine, but not live trading. Not sure if you realized this.
I am using intraday bars, but I would like to know the reason that it will never work on daily bars. Sheesh, I learn something every day.