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

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > MultiCharts


Exit all positions at last bar before market close with Renko chart type
Started:October 31st, 2016 (03:10 PM) by alex20037 Views / Replies:133 / 7
Last Reply:November 15th, 2016 (01:12 PM) Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike
     

Reply
 
Thread Tools Search this Thread

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

Old October 31st, 2016, 03:10 PM   #1 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 18 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 03:24 PM.
Reply With Quote
     

Old November 1st, 2016, 12:36 AM   #2 (permalink)
Trading Apprentice
Denver CO USA
 
Futures Experience: None
Platform: NT, JForex, Mql4 & 5
Broker/Data: FXCM
Favorite Futures: Forex
 
Posts: 23 since Sep 2016
Thanks: 0 given, 9 received

Just use the function

If CurrentTime > 1500 Then
return true;

it uses your local computer time though not the broker.

Reply With Quote
     

Old November 1st, 2016, 12:46 AM   #3 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 18 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
     

Old November 1st, 2016, 06:04 AM   #4 (permalink)
 Vendor: abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,151 since Apr 2013
Thanks: 191 given, 648 received


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
     

Old November 1st, 2016, 08:55 AM   #5 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 18 since Oct 2016
Thanks: 2 given, 3 received

Futures Edge on FIO

Are you a NinjaTrader user?

 
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
     

Old November 1st, 2016, 10:54 AM   #6 (permalink)
 Vendor: abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,151 since Apr 2013
Thanks: 191 given, 648 received

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
     

Old November 1st, 2016, 10:58 AM   #7 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 18 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
     

Old November 15th, 2016, 01:12 PM   #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 01:38 PM.
Reply With Quote
     

Reply



futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > MultiCharts > 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)
 

Al Brooks: Stop Losing when a Good Trade goes Bad, Correcting Mistakes

Elite only
 

Trading Technologies: Algo Design Lab hands-on

Dec 13

Normal webinar schedule resumes after the holidays

January
     

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


All times are GMT -4. The time now is 06:00 PM.

Copyright © 2016 by 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 2016-12-08 in 0.11 seconds with 19 queries on phoenix via your IP 54.159.129.152