Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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 bool TimeToExit() {
// Else, when backtesting, use the bar time
if (Bars.TimeValue.TimeOfDay >= exitTime)
return true;
else
return false;
}
}
}
Can you help answer these questions from other members on NexusFi?
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.
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.
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.
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.
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.