Time exit for Amibroker

I would like to add a function that can close all long or short position at 16:10:00 everyday

How to add this time exit function to the following simple program?

AvgLine = MA (50);

Buy=Cover=Cross(C, AvgLine);
Sell=Short=Cross(
AvgLine ,C);
Buy = Exrem(Buy,Sell);
Buy = Exrem(Sell
,Buy);

Many Thanks!!!
 
Haha....no la. I am new comer and don't which Sub Fornum is suitable for this question....

Many Thanks for your prompt reply~~~
 
Hey ST.M
I got another question that yesterday Close<MA(50) but today gapup, Close >MA(50)

and it BUY immediately....
If for intraday trade, I want to make it cross the MA(50) within trading hours, then begin day trade, how to write it?

Many Thanks!!!
 
buystartcon = (Ref(L,-1)<Ref(bs,-2) AND Ref(C,-1)>Ref(bs,-2))AND (NOT MarketClose);
shortstartcon = (Ref(H,-1)>Ref(bs,-2) AND Ref(C,-1)<Ref(bs,-2))AND (NOT MarketClose);

if (buystartcon OR shortstartcon==True )

{
Buy=Cross(C,bs)<=sincemko AND Ref(C,-1)>Ref(bs,-1) AND (NOT MarketClose);
Cover=Cross(C,bs)<=sincemko AND Ref(C,-1)>Ref(bs,-1) OR TimeNum() > stoptime;
Short=Cross(bs,c)<=sincemko AND Ref(C,-1)<Ref(bs,-1) AND (NOT MarketClose);
Sell=Cross(bs,c)<=sincemko AND Ref(C,-1)<Ref(bs,-1) OR TimeNum() > stoptime;


Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );
}


I want to start trade since the "buystartcon" OR "sellstartcon" occurred
if it occur, then keep doing the (Buy Sell Short Cover) until Market Close

But no matter how I try, it still show Error, would u pls give me some program logic help.
Haha....Thanks!!!
 
Back
Top