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



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


Discussion in MultiCharts

Updated by crescendo
      Top Posters
    1. looks_one alex20037 with 4 posts (0 thanks)
    2. looks_two ABCTG with 2 posts (0 thanks)
    3. looks_3 maryfromcolorado with 1 posts (0 thanks)
    4. looks_4 crescendo with 1 posts (0 thanks)
    1. trending_up 1,055 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 7 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,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
 

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

(login for full post details)
  #1 (permalink)
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
 
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

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;
}
}
}

Reply With Quote

Can you help answer these questions
from other members on futures io?
Price Down, Volume Up, Open Interest Down
Traders Hideout
Looking freelancer for MT4 Indicator
Platforms and Indicators
help to convert from thinkscript to ninjascript
NinjaTrader
Horizontal Line Indicator
Platforms and Indicators
Time & Sales Filter Size ES/NQ
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Legal question and need desperate help
89 thanks
Building a high-performance data system
15 thanks
New Computer Build
11 thanks
Risk reward question
11 thanks
Is Orderflow An Outdated Concept?
11 thanks
 
(login for full post details)
  #2 (permalink)
Denver CO USA
 
 
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
 
(login for full post details)
  #3 (permalink)
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: 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
 
(login for full post details)
  #4 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,189 since Apr 2013
Thanks: 385 given, 1,425 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

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #5 (permalink)
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: 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
 
(login for full post details)
  #6 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,189 since Apr 2013
Thanks: 385 given, 1,425 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

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #7 (permalink)
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: 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
 
(login for full post details)
  #8 (permalink)
Newark DE
 
Experience: Advanced
Platform: Multicharts
Trading: 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.

Reply With Quote


futures io Trading Community Platforms and Indicators MultiCharts > Exit all positions at last bar before market close with Renko chart type


November 15, 2016


Upcoming Webinars and Events
 

Getting Comfortable with Price Action Patterns w/Earn2Trade

Aug 4
 

Live Video Panel: Ask Me Anything w/Ironbeam Brokerage

Aug 6
     



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