NexusFi: Find Your Edge


Home Menu

 





Bot Trading - MCL Futures


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one syswizard with 30 posts (6 thanks)
    2. looks_two kevinkdog with 26 posts (27 thanks)
    3. looks_3 SMCJB with 9 posts (13 thanks)
    4. looks_4 Hulk with 9 posts (20 thanks)
      Best Posters
    1. looks_one Hulk with 2.2 thanks per post
    2. looks_two FastNCurious with 1.8 thanks per post
    3. looks_3 SMCJB with 1.4 thanks per post
    4. looks_4 kevinkdog with 1 thanks per post
    1. trending_up 22,180 views
    2. thumb_up 114 thanks given
    3. group 457 followers
    1. forum 119 posts
    2. attach_file 15 attachments




 
Search this Thread

Bot Trading - MCL Futures

  #1 (permalink)
 gftrader 
Cleveland, Ohio
 
Experience: Advanced
Platform: Tradestation
Trading: Futures
Posts: 14 since Aug 2022
Thanks Given: 6
Thanks Received: 3

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!

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146


gftrader View Post
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.

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.

Reply With Quote
Thanked by:
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,357


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);

Follow me on Twitter Reply With Quote
  #4 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,175
Thanks Received: 6,020

@kevinkdog

Thanks for sharing the strat.

Could you explain the close-close(65) crosses > or < 0

Does the stopl mean 3000 dollars with a risk:reward of 1.5?

Reply With Quote
Thanked by:
  #5 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,357


trendisyourfriend View Post
@kevinkdog

Thanks for sharing the strat.

Could you explain the close-close(65) crosses > or < 0

Does the stopl mean 3000 dollars with a risk:reward of 1.5?

If the previous bar close-close[65] was less than 0, and now the current bar close-close[65] is greater than 0, that is a cross above 0.

stopl=3000 and profit target=1.5*3000 = 4500, but these are not the only exits. There could be a reverse trade (long to short).

Follow me on Twitter Reply With Quote
  #6 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146

You need to re-run the backtest with
 
Code
SetProfitTarget(stopl*fac)
removed.
Implement a trailing stop.....much better.

Reply With Quote
Thanked by:
  #7 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,357


syswizard View Post
You need to re-run the backtest with
 
Code
SetProfitTarget(stopl*fac)
removed.
Implement a trailing stop.....much better.



A better backtest is not the end goal here.

But feel free to share your trailing stop code if you want (I hope it is not setdollartrailing or setperecenttrailing).

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146


kevinkdog View 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.
 
Code

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;


Reply With Quote
  #9 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,357

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).

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146



kevinkdog View 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 View Post
I'm curious, for the strategy I gave, what did you see that made you want to make it better?

Which strategy ?

kevinkdog View Post
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.

Reply With Quote




Last Updated on September 23, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts