PureBytes Links
Trading Reference Links
|
Thank you Barry.
As usual your tips are useful.
To permanently display the trading arrows and keep a visual history of
the previous trades, I am still searching to calculate automatically the
closing time on the last close related to the interval() displayed. For
intraday backtesting and real trading as well.
I keep your excellent idea to define the param step as 100 to jump one
minute and it does not matter if the minute is 61 to 99. It's more simple.
Best regards
Barry Scarborough a écrit :
>
>
> I suggest you don't use timenum(). If the market volume goes down there
> is no guarantee you will send the order before the market closes. Miss a
> tick it will not close when you think it will. Besides unless you use
> LastValue(TimeNum()) when you move your cursor onto a bar then that is
> what is returned by timenum. If you use the lastValue then it is safe to
> move your cursor.
>
> This is the way my program does it:
>
> // trading time parameters in hhmmss, step is one minute intervals
>
> OpenTime = Param("Open time", 93000, 0, 235959, 100);
> CloseTime = Param("Close time",155800, 0, 235959, 100); // set early
>
> // set closeTime early so your trades will have time to close that day.
> I suggest you use MKT GTC orders so they will close during the night if
> they do not close before the close time. Some folks think a MKT order
> will fill immediately. Not so. It will not close until someone buys it
> and that can be seconds, minutes or hours later. If you want to be flat
> before the real close time pay close attention to the volume and set
> closeTime even earlier, especially if the volume is low for that ticker
> and it does not trade after hours.
>
> Set you system clock to the same time your data provider either manually
> or with a clock program so it is close to real time. My system clock can
> get off TWS 30 seconds during the day, or more.
>
> Then do the following:
>
> sysTime = now(4); // this is your system clock not bar time
> tradeTime = sysTime >= OpenTime AND sysTime <= CloseTime;
> CloseTime = sysTime > CloseTime + 10;
>
> The closeTime + 10 will close your positions 10 seconds after the time
> you specify as the close time. If also stops collisions when you send an
> order seconds before the close time and immediately try to cancel or
> close it.
>
> // your logic will only send orders during your trading time
> Buy = tradeTime AND yourBuyLogic;
> Sell = tradeTime and yourSellLogic;.
> ditto with short and cover.
>
> if(CloseTime) cancel all unfilled orders.
>
> if(CloseTime + 5) close all positions
> The 5 second delay gives TWS or your broker time to cancel the orders
>
> if(CloseTime + 10) close all positions again to make sure it happens
> If you monitor status and the position number = 0 you don't have to do
> this but it won't hurt.
>
> If you are using IBs TWS then there are functions that will cancel or
> close all orders.
>
> Barry
>
> --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>,
> reinsley <reinsley@xxx> wrote:
> >
> >
> >
> > Hi,
> >
> > I do that way. Not the best code as I did not find yet how to deal with
> > interval().
> > I code manually 205500 to close at 210000 in 5 minutes time period.
> > I code manually 213000 to close at 220000 in 30 minutes time period...
> >
> > Regards
> >
> > // Defines market hours
> > MarketOpen = 080000;
> > MarketClose = 205500;// in 5 minute interval
> > MArketON = TimeNum() >= MarketOpen;
> > MarketOFF = TimeNum() >= MarketClose ;
> > MArketON = IIf( MArketOFF == 1, 0, 1 );
> >
> > Buy = [ your conditions] AND MArketON;
> > Sell = [ your conditions] OR MarketOFF;
> > Short = [ your conditions] AND MarketON;
> > Cover = [ your conditions] OR MArketOFF;
> >
> > shape = IIf( Buy , ExRem( Buy, Sell ) * shapeUpArrow, ExRem( Sell, Buy )
> > * shapeDownArrow );
> > PlotShapes( shape, IIf( Buy, colorDarkGreen, colorDarkRed ), 0, IIf(
> > Buy, Low, High ) );
> > shape2 = IIf( Cover , ExRem( Cover, Short ) * shapeUpArrow, ExRem(
> > Short, Cover ) * shapeDownArrow );
> > PlotShapes( shape2, IIf( Cover, colorDarkGreen, colorDarkRed ), 0, IIf(
> > Cover, Low, High ) );
> >
> > zeek ing a écrit :
> > >
> > >
> > > hello,
> > >
> > > anyone know the code for a system to close all open positions when the
> > > market closes for that day.
> > >
> > > Basically a day trading position?????
> > >
> > > Then at the open of the next days sessions the system start again.....
> > >
> > >
> > > thanks
> > > zeek
> > >
> > >
> > >
> >
>
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|