Help - Code to trade between specified time. - EasyLanguage Programming | futures io social day trading
futures io futures trading


Help - Code to trade between specified time.
Updated: Views / Replies:301 / 8
Created: by Edwin Lefevre Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Help - Code to trade between specified time.

  #1 (permalink)
Scotland
 
 
Posts: 16 since May 2019
Thanks: 5 given, 0 received

Help - Code to trade between specified time.

I'm trying to set my strategy to trade between 1705 and 1505.

When i put the following code in the backtest results show 0 - the strategy is not running.

if time >= 1705 and time <= 1505 then
begin;

without this line of code the strategy runs as intended. So I'm guessing I am putting it wrong or missing something else?

Help much appreciated, thanks!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Trading Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 2,127 since Apr 2013
Thanks: 380 given, 1,365 received


Edwin Lefevre,

welcome to futures.IO. The time can't be later than 1700 and at the same time be earlier than 1500, that's why your condition will never be evaluated to true. Using the logical OR instead of AND will do what you have in mind as the time can be later than 1700 or before 1505. When the time is between 1505 and 1700 neither of the two checks would evaluate to true and the condition would be false.

Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
  #4 (permalink)
Scotland
 
 
Posts: 16 since May 2019
Thanks: 5 given, 0 received

Very simple answer - I would have kept struggling for hours. Just started coding and although easier than I thought, I still make simple mistakes.

Thanks!

Reply With Quote
 
  #5 (permalink)
Agoura Hills, CA USA
 
Trading Experience: Intermediate
Platform: Tradestation
Broker/Data: TradeStation
Favorite Futures: Futures & Equities
 
numberjuani's Avatar
 
Posts: 107 since Apr 2019
Thanks: 6 given, 74 received


Edwin Lefevre View Post
Very simple answer - I would have kept struggling for hours. Just started coding and although easier than I thought, I still make simple mistakes.



Thanks!



Edwin you could also tag your first bar and then count bars from it. You would do
If time = 1700 then firstbar = barnumber;
If barnumber < firstbar + (your counter) then begin



Sent using the futures.io mobile app

Reply With Quote
The following 2 users say Thank You to numberjuani for this post:
 
  #6 (permalink)
Scotland
 
 
Posts: 16 since May 2019
Thanks: 5 given, 0 received

Hi guys I have a follow up question from this. I have been struglinng with getting my strategy to stop early on specified (holidays) days.

I have the following so far:


if date <= 1191127 and time <= 1455 or time >= 1705 then

if date = 1191128 and time <= 1145 or time >= 1705 then
if date = 1191129 and time <= 1145 or time >= 1705 then

if date >= 1191130 and time <= 1455 or time >= 1705 then
begin;

{entry orders}

....

{Holiday close orders}

If MarketPosition >0 and date = 1191128 and time = 1150 then
sell("Cover Long") next bar at open;

If MarketPosition <0 and date = 1191128 and time = 1150 then
buytocover ("Cover Short") next bar at open;

{Holiday close order}

If MarketPosition >0 and date = 1191129 and time = 1150 then
sell("Cover Long") next bar at open;

If MarketPosition <0 and date = 1191129 and time = 1150 then
buytocover ("Cover Short") next bar at open;


**edit**

Think I potentially solved my problem.

Var:
closing_time (0);

if date = 1191128 then
closing_time = 1155 else
closing_time = 1455;

if date = 1191129 then
closing_time = 1155 else
closing_time = 1455;

if time <= closing_time or time >= 1705 then
begin;


Last edited by Edwin Lefevre; November 24th, 2019 at 06:47 AM.
Reply With Quote
 
  #7 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Trading Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 2,127 since Apr 2013
Thanks: 380 given, 1,365 received

Edwin Lefevre,

when you are combining AND and OR in a condition it can make sense to use brackets to ensure that the code is evaluated in the order that you want.
 
Code
if date <= 1191127 and ( time <= 1455 or time >= 1705 ) then
Regards,

ABCTG



Edwin Lefevre View Post
Hi guys I have a follow up question from this. I have been struglinng with getting my strategy to stop early on specified (holidays) days.

I have the following so far:


if date <= 1191127 and time <= 1455 or time >= 1705 then

if date = 1191128 and time <= 1145 or time >= 1705 then
if date = 1191129 and time <= 1145 or time >= 1705 then

if date >= 1191130 and time <= 1455 or time >= 1705 then
begin;

{entry orders}

....

{Holiday close orders}

If MarketPosition >0 and date = 1191128 and time = 1150 then
sell("Cover Long") next bar at open;

If MarketPosition <0 and date = 1191128 and time = 1150 then
buytocover ("Cover Short") next bar at open;

{Holiday close order}

If MarketPosition >0 and date = 1191129 and time = 1150 then
sell("Cover Long") next bar at open;

If MarketPosition <0 and date = 1191129 and time = 1150 then
buytocover ("Cover Short") next bar at open;


**edit**

Think I potentially solved my problem.

Var:
closing_time (0);

if date = 1191128 then
closing_time = 1155 else
closing_time = 1455;

if date = 1191129 then
closing_time = 1155 else
closing_time = 1455;

if time <= closing_time or time >= 1705 then
begin;


Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #8 (permalink)
Scotland
 
 
Posts: 16 since May 2019
Thanks: 5 given, 0 received

Hey Abctg, thanks for the tip.

Can I ask if my code makes sense to you? Using an if, then, else, statement to change a variable.

closing_time (0);

if date = 1191128 then
closing_time = 1155 else
closing_time = 1455;

Reply With Quote
 
  #9 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Trading Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 2,127 since Apr 2013
Thanks: 380 given, 1,365 received

Edwin Lefevre,

using different values for variables according to the outcome of other checks (like dates in your case) is perfectly fine.

Regards,

ABCTG


Edwin Lefevre View Post
Hey Abctg, thanks for the tip.

Can I ask if my code makes sense to you? Using an if, then, else, statement to change a variable.

closing_time (0);

if date = 1191128 then
closing_time = 1155 else
closing_time = 1455;


Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:

Reply



futures io > > > > > Help - Code to trade between specified time.

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Show us your trading desks and win $1,400 in prizes w/Earn2Trade

November
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mini Nikkei 225 Setting Trade Sessions?? MC jakobe MultiCharts 3 December 12th, 2016 07:22 PM
DrawRegion between MAs - Color between bars? - help required techoli NinjaTrader Programming 5 November 14th, 2013 11:47 PM
Setting effective trade zones Stonemtn Emini and Emicro Index Futures Trading 4 August 13th, 2013 05:27 PM
Good Trade, Bad Trade, Winning Trade, Losing Trade David_R Traders Hideout 2 April 16th, 2013 04:51 PM
Best times to trade CL Gavin Commodities Futures Trading 3 January 25th, 2013 11:32 AM


All times are GMT -4. The time now is 06:32 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 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