PureBytes Links
Trading Reference Links
|
i have wrote a strategy that work with interactivebrokers
there are a mistake code but i don't find it's
can you help to find this error
many thanks in advance
_SECTION_BEGIN("mv_gx15.2");
/* strategia Mv_Gx15.2 -----------------by Vincenzo Marino
22 settembre 2008 -----------------------------------
rel 1.01 da utilizzarsi sul DAX Con frame di 15'
aggiornare il ticket ogni 3 mesi */
ibc = GetTradingInterface("IB");
sz = 1; //numero contratti
TimeFrameSet(in15Minute);
Plot(C,"C",colorBlack,64);Title=Name()+" ,";
//Parametri
tick = 8;
tm0 = int(080000); //fascia mattino
tm1 = int(120100);
tm2 = int(151400); // fascia pomeriggio
tm3 = int(235900);
/*TPL = Take profit Long in valore assoluto da aggiungere al prezzo
di buy equivale es 400 =(16/0.5)*12.5
TPS = Take Profit short
SLL = Stoo loss lons
SLS = Stop loss short
sz = numro Contratti
tick = minimo spostamento
tickvalue = valore del tick
*/
if (Name() == "fdax dec 08-dtb-fut") {sz = 1; tick = 0.50; tickvalue
= 12.50; TPL = 32; TPS = 8; SLL = 8; SLS = 48; tn = 8; }
//indicatori
Mv_low= L > Ref(L,-1) AND Ref(L,-2) > Ref(L,-1) AND Ref(C,-1)<
Ref(O,-1) AND C > O;
Mv_hi = H < Ref(H,-1)AND Ref(H,-2) < Ref(H,-1) AND C < O;
Up_trend =L > Ref(L,-1) AND H > Ref(H,-1);
down_trend = L < Ref(L,-1) AND H < Ref(H,-1);
adesso = int(Now (4));
Lmprice = 0; STprice = 0;
pos = ibc.GetPositionSize( Name() );
_TRACE("Pos :"+pos);
//L1
if (pos == 0 )
{ // inizio ciclo se 0 posizioni
_TRACE("Passa");
sz ==1;
Buy = Mv_low == 1 AND up_trend == 1 AND
((C - O)< tick) AND
(adesso > tm0 AND adesso < tm1) AND
(adesso >tm2 AND adesso < tm3) AND
RSIa(C,5) < 60 ;
_TRACE("L1 "+Buy);
for( i = 0; i < 1; i++ )
{
if( Buy[i] == 1 )
{
_TRACE("L1 "+Buy);
parentID = ibc.PlaceOrder( Name(), "BUY", sz, "stp", 0, H+tick,
"DAY", True );
ibc.PlaceOrder(Name(), "SELL", sz, "LMT", LastValue( C )+TPL, 0,
"DAY", True, 0, "", parentID );
ibc.PlaceOrder(Name(), "SELL", sz, "STP", LastValue( C )-SLL,
LastValue( C )-SLL, "DAY", True, 0, "", parentID );
PlotShapes(IIf(Buy,shapeDigit1,shapeNone),colorBlue);
}
}
}
if (pos < 0 ) // Short attivo
{
sz = pos *-2;
Buy = Mv_low == 1 AND up_trend == 1 AND
((C - O)< tick) AND
(adesso > tm0 AND adesso < tm1) AND
(adesso >tm2 AND adesso < tm3) AND
RSI(C,5) < 60 ;
for( i = 0; i < 1; i++ )
{
if( Buy[i] == 1 )
{
_TRACE("L1b "+Buy);
parentID = ibc.PlaceOrder( Name(), "BUY", sz, "stp", 0, H+tick,
"DAY", True );
ibc.PlaceOrder(Name(), "SELL", sz, "LMT", LastValue( C )+TPL, 0,
"DAY", True, 0, "", parentID );
ibc.PlaceOrder(Name(), "SELL", sz, "STP", LastValue( C )-SLL,
LastValue( C )-SLL, "DAY", True, 0, "", parentID );
PlotShapes(IIf(Buy,shapeDigit1,shapeNone),colorBlue);
}
}
}
// Lx1
if (pos >0 ) // Inizio Ciclo
{
sz = pos ;
Sell = mv_hi ==1 AND down_trend ==1 AND
((C - O)< tick) AND
RSI(C,5) < 10 ;
for( i = 0; i < 1; i++ )
{
if( Sell[i] ==1 )
{
_TRACE("Lx1 "+Sell);
ibc.PlaceOrder( Name(), "SELL", sz, "MKTCLS", 0, 0, "DAY", True );
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorBlue);
}
}
}
//S1
if (pos == 0 )
{
sz ==1;
Short = mv_hi ==1 AND down_trend ==1 AND
((C - O)< tick) AND
(adesso > tm0 AND adesso < tm1) AND
(adesso >tm2 AND adesso < tm3) AND
RSIa(C,5) < 10 ;
_TRACE("S1 "+Short);
for( i = 0; i < 1; i++ )
{
if( Short[i] ==1 )
{
_TRACE("S1 "+Short);
parentID = ibc.PlaceOrder( Name(), "SELL", sz, "stp", 0, L-tick,
"DAY", True );
ibc.PlaceOrder(Name(), "BUY", sz, "LMT", LastValue( C )-TPS, 0,
"DAY", True, 0, "", parentID );
ibc.PlaceOrder(Name(), "BUY", sz, "STP", LastValue( C )+SLS,
LastValue( C )+SLS, "DAY", True, 0, "", parentID );
PlotShapes(IIf(Short,shapeDigit1,shapeNone),colorRed);
}
}
}
if (pos > 0 )
{
sz = pos *2;
Short = mv_hi ==1 AND down_trend ==1 AND
((C - O)< tick) AND
(adesso > tm0 AND adesso < tm1) AND
(adesso >tm2 AND adesso < tm3) AND
RSIa(C,5) < 10 ;
for( i = 0; i < 1; i++ )
{
if( Short[i] ==1 )
{
_TRACE("S1b "+Short);
parentID = ibc.PlaceOrder( Name(), "SELL", sz, "stp", 0, L-tick,
"DAY", True );
ibc.PlaceOrder(Name(), "BUY", sz, "LMT", LastValue( C )-TPS, 0,
"DAY", True, 0, "", parentID );
ibc.PlaceOrder(Name(), "BUY", sz, "STP", LastValue( C )+SLS,
LastValue( C )+SLS, "DAY", True, 0, "", parentID );
PlotShapes(IIf(Short,shapeDigit1,shapeNone),colorRed);
}
}
}
// Sx1
if (pos <0 )
{
sz = pos ;
Cover = Mv_low == 1 AND up_trend == 1 AND
((C - O)< tick) AND
RSIa(C,5) > 60 ;
for( i = 0; i < 1; i++ )
{
if( Cover[i] ==1 )
{
_TRACE("Sx1 "+Cover);
ibc.PlaceOrder( Name(), "buy", sz, "MKTCLS", 0, 0, "DAY", True );
PlotShapes(IIf(Cover,shapeUpArrow,shapeNone),colorRed);
}
}
}
------------------------------------
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
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/
|