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


Exit all positions at last bar before market close with Renko chart type
Started: by alex20037 Views / Replies:188 / 7
Last Reply: 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

  #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 03: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: 31 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)
 Vendor: abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,231 since Apr 2013
Thanks: 199 given, 693 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
 
  #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

Futures Edge on FIO
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)
 Vendor: abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,231 since Apr 2013
Thanks: 199 given, 693 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
 
  #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 01: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)
 

NinjaTrader 8: Tips and Tricks (part 2)

Mar 2
 

An Afternoon With FIO member @michaelleemoore

Elite only
 

Jigsaw Trading: Keys to successfully trading the open

Mar 9

Macro view: Trump Market Risk w/Piers Curran @ Amplify Trading

Elite only

Reading the Psychology of the Market w/Brett Steenbarger & Trading Technologies

Elite only

Hybrid Machine Learning (R and TradeStation) w/Murray Ruggiero

Elite only

Spring Grains Outlook w/Sean Lusk @ Walsh Trading

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
UniRenko, Universal Renko Bar Type monpere NinjaTrader 562 February 9th, 2017 09:01 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 Emini 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 03:47 PM.

no new posts
Page generated 2017-02-24 in 0.11 seconds with 19 queries on phoenix via your IP 54.146.184.210