Time exit for Amibroker

Discussion in 'Automated Trading' started by ben.lai, Aug 29, 2014.

  1. ben.lai

    ben.lai

    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!!!
     
  2. ST.M

    ST.M

  3. ben.lai

    ben.lai

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

    Many Thanks for your prompt reply~~~
     
  4. Sergio77

    Sergio77

    if time = hh:mm then exit:)
     
  5. ST.M

    ST.M


    Wrong
     
    ben.lai likes this.
  6. ben.lai

    ben.lai

    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!!!
     
  7. ST.M

    ST.M

    Lost in translation. Don't quite understand.
     
  8. ben.lai

    ben.lai

    Haha...I tried and get it done la.
    Thanks for help!!!

    Hey ST,
    I used to trade HK market, how about you?
     
  9. ben.lai

    ben.lai

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