using System;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class EOD_Close : SignalObject
{
private IOrderMarket EOD_LX;
public EOD_Close(object ctx) :
base(ctx)
{
TimeEntry="12:00:00";
}
[Input]
public string TimeEntry { get; set; }
protected override void Create()
{
EOD_LX = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "EOD_LX", EOrderAction.BuyToCover));
}
protected override void CalcBar()
{
DateTime TradeTime = Convert.ToDateTime(TimeEntry);
if ((DateTime.Now.TimeOfDay <= TradeTime.TimeOfDay) && (CurrentPosition.Side == EMarketPositionSide.Flat))
{
EOD_LX.Send();
}
}
}
Entry only until specified time
Entry only until specified time
Hello, I need to solve condition which is responsible for making entries in the markets only until specified Time.. For exmaple I want to make entries only from 9:30 until 12:00.. The start of trading session is set in session template and now I need to force algorithm to make entries only until specified time in TimeEntry variable..Is it OK? Because it doesn't work and it seems to have problems with conversion of the time..
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Entry only until specified time
Hello snuff,
In order to achieve your goal please use Bars.TimeValue.TimeOfDay instead of DateTime.Now.TimeOfDay.
In order to achieve your goal please use Bars.TimeValue.TimeOfDay instead of DateTime.Now.TimeOfDay.