Entry only until specified time

Questions about MultiCharts .NET and user contributed studies.
snuff
Posts: 6
Joined: 21 Jul 2013
Been thanked: 1 time

Entry only until specified time

Postby snuff » 24 Jul 2013

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..

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

}

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Entry only until specified time

Postby Henry MultiСharts » 29 Jul 2013

Hello snuff,

In order to achieve your goal please use Bars.TimeValue.TimeOfDay instead of DateTime.Now.TimeOfDay.


Return to “MultiCharts .NET”