Exit all positions at last bar before market close with Renko chart type - MultiCharts | futures io social trading
futures io futures trading


Exit all positions at last bar before market close with Renko chart type
Updated: Views / Replies:287 / 7
Created: by alex20037 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 90,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
 

Exit all positions at last bar before market close with Renko chart type

  #1 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

Exit all positions at last bar before market close with Renko chart type

I am trying to automatically close all open positions at last bar before market closes (4pm EST), but in a Renko chart type, because it is time independent then doesn't work. Works fine for regular candle chart. I guess there should be a way to do this. Any help appreciated please, this is the relevant portion of the code I have:

using System;

namespace PowerLanguage.Strategy {
[IOGMode(IOGMode.Enabled)]
public class Custom_Strat: SignalObject {
public Custom_Strat(object _ctx):base(_ctx){
}

private IOrderMarket bto, sto, btc, stc;
private TimeSpan exitTime;

[Input]
public string XTime { get; set; }

private IOrderMarket buy_order;
protected override void Create() {
bto = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Buy));
sto = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.SellShort));
btc = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.BuyToCover));
stc = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Sell));

XTime = "15:55";
}
protected override void StartCalc() {

exitTime = ConvertToTime(XTime);
}
protected override void CalcBar(){

if (TimeToExit()) {
if (StrategyInfo.MarketPositionAtBroker < 0) {
btc.Send(CurrentPosition.OpenLots);
}
if (StrategyInfo.MarketPositionAtBroker > 0) {
stc.Send(CurrentPosition.OpenLots);
}
}
}

private TimeSpan ConvertToTime(string timeToConvert) {
DateTime dt = DateTime.ParseExact(timeToConvert, "H:mm",
System.Globalization.CultureInfo.InvariantCulture);

return dt.TimeOfDay;
}

private bool TimeToExit() {
// Else, when backtesting, use the bar time
if (Bars.TimeValue.TimeOfDay >= exitTime)
return true;
else
return false;
}
}
}


Last edited by alex20037; October 31st, 2016 at 02:24 PM.
Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Denver CO USA
 
Futures Experience: None
Platform: NT, JForex, Mql4 & 5
Broker/Data: FXCM
Favorite Futures: Forex
 
Posts: 32 since Sep 2016
Thanks: 0 given, 13 received

Just use the function

If CurrentTime > 1500 Then
return true;

it uses your local computer time though not the broker.

Reply With Quote
 
  #3 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received



maryfromcolorado View Post
Just use the function

If CurrentTime > 1500 Then
return true;

it uses your local computer time though not the broker.

Thank you very much for your help. The problem is the Renko bars, so even if the function returns true now, the order to close won't be sent until next bar, which could be another 5, 10 minutes. I think another way to ask is, what would be best way to have the strategy send the order to close right after that function returns true, without waiting for the next bar or waiting for the current bar to finish?
Thanks again.

Reply With Quote
 
  #4 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,373 since Apr 2013
Thanks: 215 given, 783 received
Forum Reputation: Legendary


alex20037 View Post
The problem is the Renko bars, so even if the function returns true now, the order to close won't be sent until next bar, which could be another 5, 10 minutes.

Why? Your code uses IOG and you send orders "market next bar" which will be the next tick when IOG is enabled. In realtime the order should be triggered on the tick that detects the time condition as being valid.

Regards,

ABCTG

Reply With Quote
 
  #5 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

My apologies for leaving that line of code there please. The problem is that if IOG would be applied globably, all orders would be triggered then next tick. But I would like normal orders to be sent at next bar, then only at next tick if that time is reached.

Sent using the futures.io mobile app

Reply With Quote
 
  #6 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,373 since Apr 2013
Thanks: 215 given, 783 received
Forum Reputation: Legendary

alex20037,

you will likely have to use IOG when you want to be able to close a trade intrabar. You could rework your code, so that the other orders are only issued at the end of a bar.

Regards,

ABCTG

Reply With Quote
 
  #7 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received


ABCTG View Post
alex20037,

you will likely have to use IOG when you want to be able to close a trade intrabar. You could rework your code, so that the other orders are only issued at the end of a bar.

Regards,

ABCTG


Got it, I think I can try to work it out this way.

Thanks everyone.

Reply With Quote
 
  #8 (permalink)
Elite Member
Newark DE
 
Futures Experience: Advanced
Platform: Multicharts
Favorite Futures: the Future
 
Posts: 4 since Dec 2015
Thanks: 0 given, 0 received

Have the exit session be timed slightly before close, put it in a separate signal script, and have that signal be IOG on. IOG should be able to be default OFF via program, and individually ON or OFF in signals themselves for signal calculation.


Last edited by crescendo; November 15th, 2016 at 12:38 PM.
Reply With Quote

Reply



futures io > > > > Exit all positions at last bar before market close with Renko chart type

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

July Journal Challenge w/$1100 in prizes from TopstepTrader

July

John @ No BS Day Trading (TBA)

Elite only

An Afternoon with FIO member Softsoap (being rescheduled)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
UniRenko, Universal Renko Bar Type monpere NinjaTrader 564 May 4th, 2017 12:45 PM
RENKO Bar Type education vitto Traders Hideout 4 December 4th, 2015 10:03 PM
Enter and exit positions within the same bar mandelmus EasyLanguage Programming 2 March 12th, 2015 09:41 AM
Looking for the most Popular Renko / Brick type bar tderrick Emini Index Futures Trading 11 August 12th, 2014 09:42 PM
how to load Median renko and LineBreakwicked type bar kieuthu59 NinjaTrader 8 April 11th, 2011 02:56 PM


All times are GMT -4. The time now is 11:34 PM.

Copyright © 2017 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
Page generated 2017-06-26 in 0.11 seconds with 20 queries on phoenix via your IP 54.224.86.148