System Cross for AmiBroker
This system was found in an English forum in which he wrote occasional formula in AFL, is a comprehensive system. They are examples of many of the functions that return values \u200b\u200bof the TWS, you can optimize Back-Testing and also automate it. I've been trying for about an hour and the code works without problems.
The purchase orders for sale are very simple, if crossing closure upward exponential moving average of N periods "Buy" if it crosses down "sale."
Copy and paste in the Formula Editor window
PointValue = 100;
NumContracts = 1;
MarginDeposit = 100;
PositionSize = NumContracts * MarginDeposit;
Range1=Optimize("range1",2,1,10,1);
Range2=Optimize("range2",2,1,10,1);
Plot(EMA( Close,range1), "Stopline", colorBlue );
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
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
Plot (1, "", colorRed, style Area
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";
< orderid ="="" oid =" ibc.PlaceOrder("> Plot(C,"",1,128);
PricesOnInclude = ParamToggle("Plot Trade Prices","HIDE
} 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, -3);
PlotShapes (IIf ( Cover, shapeHollowUpArrow, shapeNone), IIf (Cover == 3,
6, IIf (Cover == 2, 7 5)), 0, L, -3);}
Here I go capture all executions that has made the system
If you test the code and you have a problem with the implementation of the signs I've enabled comments so that you can write and see if together we can solve them. Greetings
Sunday, April 29, 2007
Tuesday, April 24, 2007
Neonatal Advanced Life Support Pre Test
3rd National Congress of Free Software based
in Falcon, specifically the city of Puerto Fijo.
interesting thing about this conference with respect to the organization was the fact that it was the first event where people of
Gulip working together with people of Falug
to give things as given, ie , perfect. Uhna of the reasons why I also know these events is unplug the people passing through here, on this occasion I had the pleasure of meeting and prometheus mogaal, plus to see people who already knew of other events and with whom I shared in these days of the event.
Now I the only one have to wait at the close of Congress in Maracaibo where they told me next RMS (apparently and according to a survey of the full conference, I'm the one wanting to see it: S)
the photos taken with the camera of my sister, and Bella are in this link
Work In Ottawa Live In Gatineau Tax
AmiBroker
As I commented to Alter this weekend I started to collect information on AmiBroker
,
I downloaded everything I've been finding out about installation, programming and automation strategies. By now surely everyone cononcerĂ¡ this program for those who do not know or want to deepen their study leave here a series of links that I found that are serving me to learn the operation.
INSTALLATION INFORMATION: In X-Trader is an excellent manual translated into Castilian in explaining what are the requirements to install it, also explains the steps to be followed for let plotting data received from the TWS. Installation Manual (Castilian X-Trader)
Some of the symbols that can plot free of TWS are:
EMDM7-GLOBEX-FUT = Future of e-mini S & P MID CAP 400 / June VTO ER2M7-GLOBEX-FUT = Future of e-mini Russell 2000 / June ESM7 VTO-GLOBEX-FUT = Future of e-mini S & P 500 / VTO June
QMM7-NYMEX-FUT = Future Mini Petrol / VTO June 07-JUN ECBOT YG mini-FUT = Future Gold / VTO June
YM JUN 07-ECBOT-FUT = Future Mini DJA / VTO June For other symbols
here is an explanation of how to configure them (English).
PROGRAMMING INFORMATION AFL:
Here the plot thickens a bit, there is no manual translated into Castilian in explaining the functions and basic instructions for programming. In this case I only found the manual in the official website and some examples of their library.
AFL Programming Manual (English AmiBroker) AFL Library (English AmiBroker)
Also once installed AmiBroker support are examples of how it should use all the features.
INFORMATION AUTOMATION STRATEGIES:
I have not found much information about this topic, the truth is that I imagined I would find more examples, however there are some tips that can serve to introduce it.
to send commands manually Manual (Castilian X-Trader)
IB Manual Controller (English AmiBroker)
Group Yahoo.
To break the ice and see if IB Controler works ( Interface for sending orders to TWS)
you upload the following code that you can copy and paste the Formula Editor window AmiBroker.
if (ibc.GetPositionSize (Name ()) == -1)
{OrderID = StaticVarGetText ("OrderID" + Name ()); OrderID = ibc.ModifyOrder (OrderID, Name (), "Buy", 2, "MKT", 0, 0, "Day "True )
StaticVarSetText (" OrderID "+ Name (), OrderID);
}}}
sales ////// Condition
Sell = Ref (C, -1) Ref (C, -2);
if (LastValue (Sell))
{
ibc = GetTradingInterface("IB");
if( ibc.IsConnected() )
{
if( ibc.GetPositionSize( Name() ) == 1 )
{
< OrderID = StaticVarGetText("OrderID"+Name());
OrderID = ibc.ModifyOrder( OrderID, Name(), "sell", 2, "MKT", 0, 0, "Day", True ); StaticVarSetText("OrderID"+Name(), OrderID);
}
}}
This system will do is buy 2 contracts when today's close is greater than yesterday's close, if the condition is not sell 2 contracts are met. In this way we develop a continuous system that is always in the market.
Note * The IBC allows you to set orders in the TWS before transmission, this is achieved with a safety mechanism that requires the supervision of each order before of a manual transmission. As this example system will transmit all orders without supervision, in case you want to do a manual transmission just change in the two parts of the code word "True " the word "False" .
Once you compile the system and insert it on the graph we see that not issue any orders to TWS. This happens because as a continuous system needs to have an open position to reinvest, so before putting the system to work we should manually run the position you have at that time. to run commands manually from the TWS have to go to order and that it will be opened a window like this:
If you set exactly what seen in the example would launch a purchase order for a contract on June Vto the future of e-mini S & P MID CAP 400 Globex. Otherwise we should set the terms of the contract that we want to implement the system.
Once the TWS have the same position as our system we can insert it on the chart and see how orders are executed automatically. For now that's it, I look forward to sharing emerging research on this program the more I know I like :-)
Greetings David
As I commented to Alter this weekend I started to collect information on AmiBroker
,
I downloaded everything I've been finding out about installation, programming and automation strategies. By now surely everyone cononcerĂ¡ this program for those who do not know or want to deepen their study leave here a series of links that I found that are serving me to learn the operation.
INSTALLATION INFORMATION: In X-Trader is an excellent manual translated into Castilian in explaining what are the requirements to install it, also explains the steps to be followed for let plotting data received from the TWS. Installation Manual (Castilian X-Trader)
Some of the symbols that can plot free of TWS are:
EMDM7-GLOBEX-FUT = Future of e-mini S & P MID CAP 400 / June VTO ER2M7-GLOBEX-FUT = Future of e-mini Russell 2000 / June ESM7 VTO-GLOBEX-FUT = Future of e-mini S & P 500 / VTO June
QMM7-NYMEX-FUT = Future Mini Petrol / VTO June 07-JUN ECBOT YG mini-FUT = Future Gold / VTO June YM JUN 07-ECBOT-FUT = Future Mini DJA / VTO June For other symbols
here is an explanation of how to configure them (English).
Here the plot thickens a bit, there is no manual translated into Castilian in explaining the functions and basic instructions for programming. In this case I only found the manual in the official website and some examples of their library.
AFL Programming Manual (English AmiBroker) AFL Library (English AmiBroker)
Also once installed AmiBroker support are examples of how it should use all the features.
INFORMATION AUTOMATION STRATEGIES:
I have not found much information about this topic, the truth is that I imagined I would find more examples, however there are some tips that can serve to introduce it.
to send commands manually Manual (Castilian X-Trader)
IB Manual Controller (English AmiBroker)
Group Yahoo.
- Finally Forum X-Trader in the software section
- we are some examples that have been posting Ahmose and to provide guidance strada.
To break the ice and see if IB Controler works ( Interface for sending orders to TWS)
you upload the following code that you can copy and paste the Formula Editor window AmiBroker.
- SYSTEM COMPARISON OF CLOSURES:
- purchase ////// Condition
- Buy = Ref (C, -1)> Ref (C, -2);
if (LastValue (Buy)) {
if (ibc.GetPositionSize (Name ()) == -1)
{OrderID = StaticVarGetText ("OrderID" + Name ()); OrderID = ibc.ModifyOrder (OrderID, Name (), "Buy", 2, "MKT", 0, 0, "Day "True )
StaticVarSetText (" OrderID "+ Name (), OrderID);
}}}
sales ////// Condition
Sell = Ref (C, -1) Ref (C, -2);
if (LastValue (Sell))
{
ibc = GetTradingInterface("IB");
if( ibc.IsConnected() )
{
if( ibc.GetPositionSize( Name() ) == 1 )
{
< OrderID = StaticVarGetText("OrderID"+Name());
OrderID = ibc.ModifyOrder( OrderID, Name(), "sell", 2, "MKT", 0, 0, "Day", True ); StaticVarSetText("OrderID"+Name(), OrderID);
}
}}
This system will do is buy 2 contracts when today's close is greater than yesterday's close, if the condition is not sell 2 contracts are met. In this way we develop a continuous system that is always in the market.
Note * The IBC allows you to set orders in the TWS before transmission, this is achieved with a safety mechanism that requires the supervision of each order before of a manual transmission. As this example system will transmit all orders without supervision, in case you want to do a manual transmission just change in the two parts of the code word "True " the word "False" .
Once you compile the system and insert it on the graph we see that not issue any orders to TWS. This happens because as a continuous system needs to have an open position to reinvest, so before putting the system to work we should manually run the position you have at that time. to run commands manually from the TWS have to go to order and that it will be opened a window like this:
If you set exactly what seen in the example would launch a purchase order for a contract on June Vto the future of e-mini S & P MID CAP 400 Globex. Otherwise we should set the terms of the contract that we want to implement the system.
Once the TWS have the same position as our system we can insert it on the chart and see how orders are executed automatically. For now that's it, I look forward to sharing emerging research on this program the more I know I like :-)
Greetings David
Monday, April 16, 2007
Juliet Cariaga, Watchful Eye
Model Markowitz on portfolio management
Searching the net information on the measures of the efficient frontier in portfolio management I found this PDF which explains the Markowitz model in a simple way by some students of the University of Basque Country-Euskal Herriko Unibertsitatea (what a name). This is the PDF hope you like it.
Searching the net information on the measures of the efficient frontier in portfolio management I found this PDF which explains the Markowitz model in a simple way by some students of the University of Basque Country-Euskal Herriko Unibertsitatea (what a name). This is the PDF hope you like it. Sunday, April 15, 2007
Can A Pressa Beat A Tosa ?
Yields Ibex 35 since 1990
Ibex 35 Annual Returns from 1990 to 2007
Currently, the average annual return of +14 rate is, 06%. annual standard deviation of 24.03%
The average Ibex 35 negative years is -16.44%
The average years positive Ibex 35
is +26.77%
Finally this is a graphic that shows the annual variations in the life of the index from 1990 to 2007
Ibex 35 Annual Returns from 1990 to 2007
Currently, the average annual return of +14 rate is, 06%. annual standard deviation of 24.03%
The average years positive Ibex 35
is +26.77%
Finally this is a graphic that shows the annual variations in the life of the index from 1990 to 2007 Barcelone Drinking Laws
Yields SP 500 since 1950
Annual Returns of S & P 500 from 1950 to 2007
Currently, the average annual return of index is +9.35%.
annual standard deviation of 16.34%
.
The average negative years the S & P 500 is -12.18%. The average plus years of S & P 500 is +17.47%.
Annual Returns of S & P 500 from 1950 to 2007
Currently, the average annual return of index is +9.35%.
annual standard deviation of 16.34%
.
The average negative years the S & P 500 is -12.18%. The average plus years of S & P 500 is +17.47%.
Film Laure 1976 Online
him for some time consegir had an image of the lost brother of
watching the adventures of Electronic Orphans , but had not gotten a picture of alberkman for comparison, until he published a very good at her blog, to see if anyone doubts the relationship of these two.
Saturday, April 14, 2007
Itunes Error System Not Modified
Returns on the DJA since 1900
If I'm not mistaken these are the returns of DJA from 1900 to the current date by reference to the first closing day of the year.
annual standard deviation of 22.15%
.
Finally this graphic returns the distribution of returns. Each point shows the profitability of a given year from the highest negative return of -56.06% in 1931 to the highest positive return of 80.87% in 1915.
The average loss of this historic negative years is -15.01%
average profit of plus years of this historic
is +19.73%
If I'm not mistaken these are the returns of DJA from 1900 to the current date by reference to the first closing day of the year.
The average (arithmetic mean) tends to oscillate between 6 and 8%. Today the average of all returns from 1900 to 2006 is +7.39%
.
annual standard deviation of 22.15%
.
Finally this graphic returns the distribution of returns. Each point shows the profitability of a given year from the highest negative return of -56.06% in 1931 to the highest positive return of 80.87% in 1915.
The average loss of this historic negative years is -15.01%
average profit of plus years of this historic
is +19.73%
Friday, April 13, 2007
Wednesday, April 4, 2007
Black Female Horse Genital
Two new systems, and CAC 40
Now that I have a good time I will have some new changes bearing the "portfolio of systems."
started to publish results of two new systems.
I I am totally in favor of diversification and asset management systems to try to reduce the standard deviation (a measure of drawdown) joint portfolio. In this case there was a good opportunity to try to reduce the risk of throwing the MR system operating with 2 contracts. This was split, operating with one on the future of the MR and the other on the future of S & P, the system is exactly the same, the only difference is that the latter I have added a trailing stop based in € uros.
The CAC 40 system is a system very similar to the future of Dax, happened to notice the results of backtesting positive results every year since the 93, the truth is that it is a market that is me starting to like it quite as the face of the future is not too can be high as the Dax or the Ibex and is also a market with sufficient liquidity and volatility as the baseline systems to generate profits (at least in back-testing).
That's all for now folks, we now have all the cards on the table! for the next few months I have no plans to add any new system so I will just enhance what we have so far (which is something).
Regards and good trading to all
dav_hurry@hotmail.com
Now that I have a good time I will have some new changes bearing the "portfolio of systems."
- 1 system on the S & P Mid Cap 400.
- Both are purely intra-day and without leaving the road, continue with the same concept (breaks of support and resistance) applied to these new markets.
-
If you look at the MR system (Mini Russell 2000) have begun publishing operations with a single contract and not to 2 as it was before, this is the following:
I I am totally in favor of diversification and asset management systems to try to reduce the standard deviation (a measure of drawdown) joint portfolio. In this case there was a good opportunity to try to reduce the risk of throwing the MR system operating with 2 contracts. This was split, operating with one on the future of the MR and the other on the future of S & P, the system is exactly the same, the only difference is that the latter I have added a trailing stop based in € uros.
The backtesting result in some improvement, the largest drawdowns of each system are given at different points and this helps to reduce the drawdown of the two systems together.
The CAC 40 system is a system very similar to the future of Dax, happened to notice the results of backtesting positive results every year since the 93, the truth is that it is a market that is me starting to like it quite as the face of the future is not too can be high as the Dax or the Ibex and is also a market with sufficient liquidity and volatility as the baseline systems to generate profits (at least in back-testing).
That's all for now folks, we now have all the cards on the table! for the next few months I have no plans to add any new system so I will just enhance what we have so far (which is something).
Regards and good trading to all
dav_hurry@hotmail.com
Subscribe to:
Posts (Atom)