I'm going to crosspost this, because it was originallyposted in the AT group.  
But I'm more interested n the Trading System (TS) aspect.  

I can't see that this system is at all successful.  It seems to trade every 
couple of bars on the 1m ER2.  I also don't see the logic of it.  If we are 
going to work together to create a system (I think that would be really fun) 
then we need to have a model that we can understand and agree on the basics of. 
 

Booker -- can you tell me what this system is supposed to do?   Why are there 2 
MAs, which are almost identical?   How fast is the system supposed to trade?  
How many points are we expecting out of each trade, etc.

Am I missing something?

thanks

chuck

  ----- Original Message ----- 
  From: Herman 
  To: [EMAIL PROTECTED] 
  Sent: Thursday, November 30, 2006 4:04 PM
  Subject: RE: [AmiBroker-at] New AT Project



  Thank you Terry,

  I created a few folders in the files section, would anybody have objections 
if we file this code in the ER2 Project folder there and name it ER2-v001?

  herman
    -----Original Message-----
    From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Terry
    Sent: November 30, 2006 10:10 AM
    To: [EMAIL PROTECTED]
    Subject: RE: [AmiBroker-at] New AT Project


    Reposted in HTML with formatting intact and one statement per line:



    ///////////////////////////////////////////////////////////////////////

    // After Edward pointed out that my code was flawed and after examining

    // the buy and sell from a back test, I think Edward is correct. There

    // is no way a buyprice can be the low of an uptrending candle at the

    // close. So I am revising my submission to buy or sell at the next days

    // open. Doing so will result in a back test that is nothing special. I

    // am also including an Optimize function. I would also like to see

    // Herman break this up into modules with different directories. If

    // anyone can improve the profits with a better idea, please feel free

    // with your suggestions. If Herman or Edward or anyone else with

    // experience wishes to rewrite this code to make it better, please do.

    // I would like to see this project turn into a very nice AT platform.

    //

    // Thanks

    // Booker

    ///////////////////////////////////////////////////////////////////////





    _SECTION_BEGIN("ER2 auto trade");



    // next 4 lines are for ER2 futures

    PointValue = 100;

    NumContracts = 1;

    MarginDeposit = 100;

    PositionSize = NumContracts * MarginDeposit;



    Range1=Optimize("range1",7,1,10,1);

    Range2=Optimize("range2",6,1,10,1);





    Plot(EMA( Close,range1), "Stopline", colorYellow );

    Buy = Ref(Cross((Close),(EMA(Close,range1))),-1);

    Buystop = Ref(EMA(Close,range1),-1);

    BuyPrice = Max(Buystop,Open);

    Sell = Ref(Cross(EMA(Close,range2),(Close)),-1);

    Sellstop = Ref(EMA(Close,range1),-1);

    SellPrice = Min(sellstop,Open);

    Short = Sell;

    Cover = Buy;



    /////////////////// Automation Code //////////////////



    PrevDT = StaticVarGet("DateTime");

    DT = LastValue(DateTime());

    NewBar = DT != PrevDT;

    StaticVarSet("DateTime",DT);

    if( NewBar )

    {

        StaticVarSetText("OrderID","");

        Plot(1,"",colorYellow,styleArea|styleOwnScale,0,1);

    }



    AutoTrading = StaticVarGet("AutoTrading");

    if( IsNull( AutoTrading ) ) StaticVarSet("AutoTrading",0);

    ATonTrigger = ParamTrigger("Start AutoTrading","START");

    AToffTrigger = ParamTrigger("Stop AutoTrading","STOP");

    if( ATonTrigger ) StaticVarSet("AutoTrading",1);

    else if( AToffTrigger ) StaticVarSet("AutoTrading",0);

    AutoTrading = StaticVarGet("AutoTrading");





    CancelALL = ParamTrigger("Cancel All Orders","CANCEL ALL");

    CloseALL = ParamTrigger("Close All Positions","CLOSE ALL");

    MAnualBuy = ParamTrigger("Manual Buy","BUY");

    MAnualSell = ParamTrigger("Manual Sell","SELL");

    LastBuy = LastValue(Buy) OR MAnualBuy;

    LastSell = LastValue(Sell) OR MAnualSell;



    ibc = GetTradingInterface("IB");

    IBcStatus = ibc.IsConnected();

    IBcStatusString = WriteIf(IBCStatus==0,"TWS Not Found", 
WriteIf(IBCStatus==1,"Connecting to TWS", WriteIf(IBCStatus==2,"TWS OK", 
WriteIf(IBCStatus==3,"TWS OK (msgs)",""))));



    if( CancelAll )

    {

        ibc.CancelAllPendingOrders();

        StaticVarSetText("OrderID","");

    }

    else if ( CloseAll )

    {

        ibc.CancelAllPendingOrders();

        ibc.CloseAllOpenPositions();

        StaticVarSetText("OrderID","");

    }



    if( IBcStatus AND AutoTrading )

    {

        OrderID = StaticVarGetText("OrderID");

        IBPosSize = ibc.GetPositionSize( Name() );

        if(IBPosSize == 0 )

        {

            if( LastBuy AND OrderID == "" )

            {

                OID = ibc.PlaceOrder( Name(), "Buy", 1, "MKT", 0, 0,

                "DAY", True );

                StaticVarSetText("OrderID",OID);

                Plot(1,"",colorBrightGreen,styleArea|styleOwnScale| 
styleNoLabel,0,1);

                _TRACE("# Pos: 0, PrevOID: "+OrderID+", Buy 1, NewOID: "+OID);

            }

            else if( LastSell AND OrderID == "" )

            {

                OID = ibc.PlaceOrder( Name(), "Sell", 1, "MKT", 0, 0, "DAY", 
True );

                StaticVarSetText("OrderID",OID);

                Plot(1,"",colorRed,styleArea|styleOwnScale|styleNoLabel,0,1);

                _TRACE("# Pos: 0, PrevOID: "+OrderID+", Sell 1, NewOID: "+OID);

            }

        }

        else if( IBPosSize < 0 )

        {

            if( LastBuy AND OrderID == "" )

            {

                OID = ibc.PlaceOrder( Name(), "Buy", 2, "MKT", 0, 0, "DAY", 
True );

                StaticVarSetText("OrderID",OID);

                Plot(1,"",colorBrightGreen,styleArea|styleOwnScale| 
styleNoLabel,0,1);

                _TRACE("# Pos: <0, PrevOID: "+OrderID+", Buy 1, NewOID: "+OID);

            }

        }

        else if( IBPosSize > 0 )

        {

            if( LastSell AND OrderID == "" )

            {

                OID = ibc.PlaceOrder( Name(), "Sell", 2, "MKT", 0, 0, "DAY", 
True );

                StaticVarSetText("OrderID",OID);

                Plot(1,"",colorRed,styleArea|styleOwnScale|styleNoLabel,0,1);

                _TRACE("# Pos: >0, PrevOID: "+OrderID+", Sell 1, NewOID: "+OID);

            }

        }

        LastOrderID = StaticVarGetText("OrderID");

        ORderStatus = ibc.GetStatus( LastOrderID , True );

        if( ORderStatus != "" ) StaticVarSetText("OrderStatus",ORderStatus);

    }

    else IBPosSize = 0;



    LastOrderID = StaticVarGetText("OrderID");

    ORderStatus = StaticVarGetText("OrderStatus");

    Title = "\n"+

    " Trading Mode: "+WriteIf( AutoTrading,"ON","OFF")+"\n"+

    " Last Signal: "+WriteIf(LastBuy,"BUY",WriteIf 
(LastSell,"SELL","NoSignal"))+"\n"+

    " IB Status: "+IBcStatusString+"\n"+

    " Last OrderID: "+LastOrderID+"\n"+

    " OrderStatus: "+ORderStatus+"\n"+

    " IBPosSize: "+NumToStr(IBPosSize,1.0)+" shares";



    Plot(C,"",1,128);

    PricesOnInclude = ParamToggle("Plot Trade Prices","HIDE|SHOW",1);

    ArrowsOnInclude = ParamToggle("Plot Trade Arrows","HIDE|SHOW",1);



    if( PricesOnInclude )

    {

        PlotShapes(IIf(Buy, shapeSmallCircle,shapeNone),5, 0,BuyPrice,0);

        PlotShapes(IIf(Sell, shapeHollowCircle,shapeNone),4,0,SellPrice,0);

        PlotShapes(IIf(Cover, shapeHollowCircle, shapeNone),5,0,CoverPrice,0);

        PlotShapes(IIf(Short, shapeSmallCircle, shapeNone),4,0,ShortPrice,0);

    }

    if( ArrowsOnInclude )

    {

        PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), 5,0,L, -20);

        PlotShapes(IIf(Sell, shapeDownArrow, shapeNone), IIf(Sell==3, 6, 
IIf(Sell==2, 7, 4)),0,H, -20);

        PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone), 4,0,H, -38);

        PlotShapes(IIf(Cover, shapeHollowUpArrow, shapeNone), IIf( Cover==3, 6, 
IIf(Cover==2, 7, 5)),0,L, -38);

    }

    _SECTION_END();

    --

    Terry 


   

[Non-text portions of this message have been removed]

Reply via email to