About Easylanguage Time Management for Entering Trades - futures io
futures io futures trading



About Easylanguage Time Management for Entering Trades


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,302 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 10 posts
    2. attach_file 3 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

About Easylanguage Time Management for Entering Trades

(login for full post details)
  #1 (permalink)
Florence
 
 
Posts: 17 since Jan 2021
Thanks: 12 given, 4 received

Hello, I am quite new to easy language, recently I wrote to exercise myself, this Signal in Multicharts to enter a trade at given day of week in a given hour in the inputs for the SP future 30 minutes chart, and exit the trade at another day of week and hour.
 
Code
input: NContracts(1),
	MyTimeEntry(1200),
	MyTimeExit(1200),
	Mystop(1000),
	Myprofit(0),
	MyBeginningDay(1),
	MyEndingDay(3);

if dayofweek(date) = MyBeginningDay and Time = MyTimeEntry then begin

	Buy ("Bias_Long") NContracts contracts this bar on close;

end;

if dayofweek(date) = MyEndingDay and Time = MyTimeExit then begin

	if marketposition <> 0 then sellshort ("Time_Exit_L") next bar high limit;
	
end;

if mystop > 0 then setstoploss(mystop);
if myprofit > 0 then setprofittarget(myprofit);
Basically it never enter the trade on Monday, I also tryed to optimize for MyBeginningDay and it never feels like it is Monday = 1...Same thing with the hour it randomly take a different hour to exit the trade on the same day most of the time.

I have quite an headache understating what can be the problem for this simple and stupid code.
I am also sure I setup properly symbol session time in quote manager, using exchange session time zone. And I also removed holidays.

-Are the bars provided by IQfeed not properly set? or is it because I am doing something wrong with the code or datafeed?

-Is there some difference between datafeed exchange time, local time and bars time?

-Any suggestions to improve the code and make it work as intended?

Reply With Quote

Can you help answer these questions
from other members on futures io?
Help get more ThinkOrSwim content on futures io!
ThinkOrSwim
Financial Modeling Prep (free to use: financialmodelingprepcom) API
Trading Reviews and Vendors
DMIC 2059 program
Traders Hideout
Select custom session template not working
TradeStation
Managing Contracts - Shares from an Indicator
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The war of the two worlds (options traders vs futures traders)
98 thanks
Big Mike in Ecuador
92 thanks
How did you learn to trade?
57 thanks
The Small Exchange (www.smallexchange.com)
46 thanks
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Cleveland Ohio/United States
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation, DeCarley, others
Trading: futures
 
Posts: 2,918 since Jul 2012
Thanks: 1,535 given, 5,718 received

I tried it, and got plenty of Monday entries (I added one print statement so you can see):

 
Code
input: NContracts(1),
	MyTimeEntry(1200),
	MyTimeExit(1200),
	Mystop(1000),
	Myprofit(0),
	MyBeginningDay(1),
	MyEndingDay(3);

if dayofweek(date) = MyBeginningDay and Time = MyTimeEntry then begin
    If MyBeginningDay=1  then print ("buy on Monday ", date);
	Buy ("Bias_Long") NContracts contracts this bar on close;

end;

if dayofweek(date) = MyEndingDay and Time = MyTimeExit then begin

	if marketposition <> 0 then sellshort ("Time_Exit_L") next bar high limit;
	
end;

if mystop > 0 then setstoploss(mystop);
if myprofit > 0 then setprofittarget(myprofit);


buy on Monday 1200106.00
buy on Monday 1200113.00
buy on Monday 1200120.00
buy on Monday 1200127.00
buy on Monday 1200203.00
buy on Monday 1200210.00
buy on Monday 1200217.00
buy on Monday 1200224.00
buy on Monday 1200302.00
buy on Monday 1200309.00
buy on Monday 1200316.00
buy on Monday 1200323.00
buy on Monday 1200330.00
buy on Monday 1200406.00
buy on Monday 1200413.00
buy on Monday 1200420.00
buy on Monday 1200427.00
buy on Monday 1200504.00
buy on Monday 1200511.00
buy on Monday 1200518.00
buy on Monday 1200525.00
buy on Monday 1200601.00
buy on Monday 1200608.00
buy on Monday 1200615.00
buy on Monday 1200622.00
buy on Monday 1200629.00
buy on Monday 1200706.00
buy on Monday 1200713.00
buy on Monday 1200720.00
buy on Monday 1200727.00
buy on Monday 1200803.00
buy on Monday 1200810.00
buy on Monday 1200817.00
buy on Monday 1200824.00
buy on Monday 1200831.00
buy on Monday 1200907.00
buy on Monday 1200914.00
buy on Monday 1200921.00
buy on Monday 1200928.00
buy on Monday 1201005.00
buy on Monday 1201012.00
buy on Monday 1201019.00
buy on Monday 1201026.00
buy on Monday 1201102.00
buy on Monday 1201109.00
buy on Monday 1201116.00
buy on Monday 1201123.00
buy on Monday 1201130.00
buy on Monday 1201207.00
buy on Monday 1201214.00
buy on Monday 1201221.00
buy on Monday 1201228.00



I also optimized for Entry hour, and got plenty of entries every hour...


Follow me on Twitter Reply With Quote
The following user says Thank You to kevinkdog for this post:
 
(login for full post details)
  #3 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little ES, GE, GC, SI & Bitcoin
 
Posts: 3,802 since Dec 2013
Thanks: 3,093 given, 7,372 received



M4STR0 View Post
 
Code
if dayofweek(date) = MyEndingDay and Time = MyTimeExit then begin
	if marketposition <> 0 then sellshort ("Time_Exit_L") next bar high limit;

Sellshort is reversing your trade from long to short, not just exiting the position. To exit and not reverse just use sell.

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #4 (permalink)
Florence
 
 
Posts: 17 since Jan 2021
Thanks: 12 given, 4 received

Thank you Kevinkdog and SMCJB, but I guess something is wrong with multicharts, once I have tradestation I will also test this in that platform perhaps it is just a problem of multicharts and iqfeed bar data. Did not know about the difference between sellshort and sell, thank you this was helpful.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Legendary Market Wizard
Cleveland Ohio/United States
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation, DeCarley, others
Trading: futures
 
Posts: 2,918 since Jul 2012
Thanks: 1,535 given, 5,718 received


M4STR0 View Post
Thank you Kevinkdog and SMCJB, but I guess something is wrong with multicharts, once I have tradestation I will also test this in that platform perhaps it is just a problem of multicharts and iqfeed bar data. Did not know about the difference between sellshort and sell, thank you this was helpful.


I get the same results in MultiCharts - I cannot duplicate the issues you mentioned.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #6 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little ES, GE, GC, SI & Bitcoin
 
Posts: 3,802 since Dec 2013
Thanks: 3,093 given, 7,372 received


M4STR0 View Post
Did not know about the difference between sellshort and sell, thank you this was helpful.

Buy and Sellshort enter new positions. If you currently have a position in the opposite direction it will both close it and enter the new position (ie reverse the position).
Buytocover and Sell will only close positions.

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #7 (permalink)
Florence
 
 
Posts: 17 since Jan 2021
Thanks: 12 given, 4 received

I did some further investigations by doing some sane debugging, I added this
 
Code
print(datetimetostring(datetime), "	", "dayofweek(d):", dayofweek(d),"		", "Time:", Time,"	", "dayofweek(date):", dayofweek(date));
to the signal and rewrote it a bit like this:
 
Code
input: NContracts(1);
input:	MyTimeEntry(2200), MyTimeExit(2200);
input: MyBeginningDay(1), MyEndingDay(3);
input:	Mystop(0), Myprofit(0), MyBreakeven(0);

print(datetimetostring(datetime), "	", "dayofweek(d):", dayofweek(d),"		", "Time:", Time,"	", "dayofweek(date):", dayofweek(date));

if Time = MyTimeEntry and dayofweek(d) = MyBeginningDay then buy ("Bias_Long") NContracts contracts next bar market;
if Time = MyTimeExit and dayofweek(d) = MyEndingDay then sell ("Bias_Short") NContracts contracts next bar at market;

setstopcontract;

if MyStop > 0 then setstoploss(Mystop);
if MyBreakeven > 0 then setbreakeven(MyBreakeven);
if MyProfit > 0 then setprofittarget(MyProfit);
The debuggin output is interesting
30/09/2020 05:00:00 dayofweek(d): 3.00 Time: 500.00 dayofweek(date): 3.00
30/09/2020 06:00:00 dayofweek(d): 3.00 Time: 600.00 dayofweek(date): 3.00
30/09/2020 09:00:00 dayofweek(d): 3.00 Time: 900.00 dayofweek(date): 3.00
01/10/2020 20:00:00 dayofweek(d): 4.00 Time:2000.00 dayofweek(date): 4.00
02/10/2020 04:00:00 dayofweek(d): 5.00 Time: 400.00 dayofweek(date): 5.00
02/10/2020 05:00:00 dayofweek(d): 5.00 Time: 500.00 dayofweek(date): 5.00
02/10/2020 06:00:00 dayofweek(d): 5.00 Time: 600.00 dayofweek(date): 5.00
02/10/2020 07:00:00 dayofweek(d): 5.00 Time: 700.00 dayofweek(date): 5.00
02/10/2020 08:00:00 dayofweek(d): 5.00 Time: 800.00 dayofweek(date): 5.00
07/10/2020 02:00:00 dayofweek(d): 3.00 Time: 200.00 dayofweek(date): 3.00
07/10/2020 08:00:00 dayofweek(d): 3.00 Time: 800.00 dayofweek(date): 3.00
08/10/2020 08:00:00 dayofweek(d): 4.00 Time: 800.00 dayofweek(date): 4.00
09/10/2020 02:00:00 dayofweek(d): 5.00 Time: 200.00 dayofweek(date): 5.00
09/10/2020 03:00:00 dayofweek(d): 5.00 Time: 300.00 dayofweek(date): 5.00
12/10/2020 04:00:00 dayofweek(d): 1.00 Time: 400.00 dayofweek(date): 1.00
12/10/2020 09:00:00 dayofweek(d): 1.00 Time: 900.00 dayofweek(date): 1.00
14/10/2020 06:00:00 dayofweek(d): 3.00 Time: 600.00 dayofweek(date): 3.00
14/10/2020 08:00:00 dayofweek(d): 3.00 Time: 800.00 dayofweek(date): 3.00
15/10/2020 05:00:00 dayofweek(d): 4.00 Time: 500.00 dayofweek(date): 4.00
15/10/2020 07:00:00 dayofweek(d): 4.00 Time: 700.00 dayofweek(date): 4.00
15/10/2020 08:00:00 dayofweek(d): 4.00 Time: 800.00 dayofweek(date): 4.00
16/10/2020 08:00:00 dayofweek(d): 5.00 Time: 800.00 dayofweek(date): 5.00
21/10/2020 07:00:00 dayofweek(d): 3.00 Time: 700.00 dayofweek(date): 3.00
21/10/2020 19:00:00 dayofweek(d): 3.00 Time:1900.00 dayofweek(date): 3.00
26/10/2020 04:00:00 dayofweek(d): 1.00 Time: 400.00 dayofweek(date): 1.00
27/10/2020 18:00:00 dayofweek(d): 2.00 Time:1800.00 dayofweek(date): 2.00
28/10/2020 04:00:00 dayofweek(d): 3.00 Time: 400.00 dayofweek(date): 3.00
28/10/2020 16:00:00 dayofweek(d): 3.00 Time:1600.00 dayofweek(date): 3.00
29/10/2020 06:00:00 dayofweek(d): 4.00 Time: 600.00 dayofweek(date): 4.00
29/10/2020 07:00:00 dayofweek(d): 4.00 Time: 700.00 dayofweek(date): 4.00
29/10/2020 09:00:00 dayofweek(d): 4.00 Time: 900.00 dayofweek(date): 4.00
30/10/2020 04:00:00 dayofweek(d): 5.00 Time: 400.00 dayofweek(date): 5.00
30/10/2020 05:00:00 dayofweek(d): 5.00 Time: 500.00 dayofweek(date): 5.00
30/10/2020 07:00:00 dayofweek(d): 5.00 Time: 700.00 dayofweek(date): 5.00
30/10/2020 08:00:00 dayofweek(d): 5.00 Time: 800.00 dayofweek(date): 5.00
02/11/2020 04:00:00 dayofweek(d): 1.00 Time: 400.00 dayofweek(date): 1.00
02/11/2020 06:00:00 dayofweek(d): 1.00 Time: 600.00 dayofweek(date): 1.00
02/11/2020 09:00:00 dayofweek(d): 1.00 Time: 900.00 dayofweek(date): 1.00
04/11/2020 02:00:00 dayofweek(d): 3.00 Time: 200.00 dayofweek(date): 3.00
05/11/2020 09:00:00 dayofweek(d): 4.00 Time: 900.00 dayofweek(date): 4.00
06/11/2020 04:00:00 dayofweek(d): 5.00 Time: 400.00 dayofweek(date): 5.00
06/11/2020 07:00:00 dayofweek(d): 5.00 Time: 700.00 dayofweek(date): 5.00
06/11/2020 08:00:00 dayofweek(d): 5.00 Time: 800.00 dayofweek(date): 5.00
09/11/2020 06:00:00 dayofweek(d): 1.00 Time: 600.00 dayofweek(date): 1.00
09/11/2020 08:00:00 dayofweek(d): 1.00 Time: 800.00 dayofweek(date): 1.00
11/11/2020 07:00:00 dayofweek(d): 3.00 Time: 700.00 dayofweek(date): 3.00
12/11/2020 08:00:00 dayofweek(d): 4.00 Time: 800.00 dayofweek(date): 4.00
16/11/2020 07:00:00 dayofweek(d): 1.00 Time: 700.00 dayofweek(date): 1.00
19/11/2020 06:00:00 dayofweek(d): 4.00 Time: 600.00 dayofweek(date): 4.00
23/11/2020 08:00:00 dayofweek(d): 1.00 Time: 800.00 dayofweek(date): 1.00
25/11/2020 00:00:00 dayofweek(d): 3.00 Time: 0.00 dayofweek(date): 3.00
25/11/2020 01:00:00 dayofweek(d): 3.00 Time: 100.00 dayofweek(date): 3.00
25/11/2020 02:00:00 dayofweek(d): 3.00 Time: 200.00 dayofweek(date): 3.00
25/11/2020 16:00:00 dayofweek(d): 3.00 Time:1600.00 dayofweek(date): 3.00
25/11/2020 20:00:00 dayofweek(d): 3.00 Time:2000.00 dayofweek(date): 3.00
25/11/2020 23:00:00 dayofweek(d): 3.00 Time:2300.00 dayofweek(date): 3.00
27/11/2020 06:00:00 dayofweek(d): 5.00 Time: 600.00 dayofweek(date): 5.00
29/11/2020 18:00:00 dayofweek(d): 0.00 Time:1800.00 dayofweek(date): 0.00
30/11/2020 09:00:00 dayofweek(d): 1.00 Time: 900.00 dayofweek(date): 1.00
11/12/2020 08:00:00 dayofweek(d): 5.00 Time: 800.00 dayofweek(date): 5.00
13/12/2020 22:00:00 dayofweek(d): 0.00 Time:2200.00 dayofweek(date): 0.00
16/12/2020 09:00:00 dayofweek(d): 3.00 Time: 900.00 dayofweek(date): 3.00
16/12/2020 16:00:00 dayofweek(d): 3.00 Time:1600.00 dayofweek(date): 3.00
17/12/2020 20:00:00 dayofweek(d): 4.00 Time:2000.00 dayofweek(date): 4.00
18/12/2020 09:00:00 dayofweek(d): 5.00 Time: 900.00 dayofweek(date): 5.00
21/12/2020 06:00:00 dayofweek(d): 1.00 Time: 600.00 dayofweek(date): 1.00

for starters the data I got ends the 21/12/2020 and looks like the day 1.00 of the week never gets to hour 22000...
Perhaps for Monday I have to use day 0 instead of 1

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Legendary Market Wizard
Cleveland Ohio/United States
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation, DeCarley, others
Trading: futures
 
Posts: 2,918 since Jul 2012
Thanks: 1,535 given, 5,718 received

It goes off of your chart time, so that is what I'd check.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #9 (permalink)
Florence
 
 
Posts: 17 since Jan 2021
Thanks: 12 given, 4 received

I am using this session time settings now, before I saw I did a mistake between the days

Open Time Close Time Session End

Sunday 17:00 Monday 16:00 X
Monday 17:00 Tuesday 16:00 X
Tuesday 17:00 Wednesday 16:00 X
Wedsnesday 17:00 Thurdsday 16:00 x
Thurdsday 17:00 Friday 16:00 x

and Exchange time in the instrument chart settings for the SP future

Anyway, now that I fixed the session time settings I see it still does not start most of the time in monday, this is really weird.

Attached Thumbnails
Click image for larger version

Name:	image_907.png
Views:	10
Size:	23.4 KB
ID:	307934   Click image for larger version

Name:	image_241.png
Views:	10
Size:	27.8 KB
ID:	307935  
Reply With Quote
 
(login for full post details)
  #10 (permalink)
Legendary Market Wizard
Cleveland Ohio/United States
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation, DeCarley, others
Trading: futures
 
Posts: 2,918 since Jul 2012
Thanks: 1,535 given, 5,718 received


Something is goofy here, because if you are using 30 minute bars, you should have a print statement printing out every 30 minutes. You don't have any print statements at 630, 730 etc, and you are missing a lot of bars at 00 times.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #11 (permalink)
Florence
 
 
Posts: 17 since Jan 2021
Thanks: 12 given, 4 received


kevinkdog View Post
Something is goofy here, because if you are using 30 minute bars, you should have a print statement printing out every 30 minutes. You don't have any print statements at 630, 730 etc, and you are missing a lot of bars at 00 times.

yes you are right in what I posted before with the debug I used 1hour time frame and not 30 minutes bars but still I think I am missing lot of bars, well I will test this when I have also tradestation data, so we are sure something is wrong in the other data provider

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > About Easylanguage Time Management for Entering Trades


Last Updated on January 5, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Finding Trading Opportunities Using Profile Charts w/Tradovate

Jan 28
 

Journal Challenge!

February
 

Battlestations!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts