[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Conditional Buy/Sell orders



PureBytes Links

Trading Reference Links

It is just a matter of building up the logic for your system.
You could use conditions based on barssince( event) to tell your
signals what to do. eg this is suggestion onlyto show how logic can
work
What you will have to do is set up a loop of logic as this type of
thing requires other signals to be defined first. Like bleow requires
sell to already be defined

Buy = Cross(blue, red) or ( barssince(sell) < barssince(short) and
cross( blue,green) );

One comment I will make is that your system looks into the future, due
to your displacement of averages, and you will not be able to trade
this as your new trade signals could disappear as more data is added.


--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm


On 2/24/06, axle_d <axle_d@xxxxxxxxx> wrote:
> I have the following code, however,I would like to trigger buy/sell
> rules only under certain conditions:
>
> 1.  Positions are entered on the cross of the Blue and red lines.
> 2.  positions are exited on the cross of the blue and green lines
> 3.  If I enter long on cross(Blue, Red)I will exit on Cross(green, blue).
> 4.  Although I have exited the initial LONG, if the BLUE does not
> cross below the RED (triggering a SHORT), BUT turns and recrosses
> above green again (usually due to short term price action), I would
> like to re-enter LONG
> 5.  Obviously there could be periods of NO POSITION.
>
> Any help greatly appreciated.
>
>
> //The Shifted EMA - Default is 3 Period and -3 Lead/Lag
> //Code Credit help  to Franklin from AB Board
>
> EMAPeriod = Param("Fast EMA",3,1,25,1);
> DisplacementPeriod = Param("Shift",-3,-25,25,1);
>
> Blue = Ref(EMA(Close,EMAPeriod),-DisplacementPeriod);
> Green = EMA(C, 5);
> Red = EMA(C, 15);
>
> //Plot the Lines
> Plot(Ref(EMA(Close,EMAPeriod),-DisplacementPeriod),"DEMA1",colorBlue,styleThick|styleLine);
> Plot(EMA(Close, 5 ), "5 Wk EMA", colorGreen, styleLine);
> Plot(EMA(Close, 15 ), "15 Wk EMA", colorRed, styleLine);
>
> //Buy and Sell Rules
>
> Buy = Cross(blue, red);
> Sell = Cross(green, blue);
> Short = Cross(red, blue);
> Cover = Cross(blue, green);
>
> for ( i = 12; i < BarCount; i++)
> {
> if( Buy[i]) PlotText ("LE" + C[i], i, L[i], colorGreen );
> if( Sell[i]) PlotText ("LX" + C[i], i, H[i], colorGreen );
> if( Short[i]) PlotText ("SE" + C[i], i, L[i], colorRed );
> if( Cover[i]) PlotText ("SX" + C[i], i, H[i], colorRed );
> }
>
> Title = Name() + " " + Date() + EncodeColor(colorIndigo) + " " + C +
> WriteVal(ROC( Close, 1) ) + "%" + EncodeColor(colorBlue) + " Three
> Shift Indicator ";
>
>
>
>
>
>
>
> 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 other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

<*> 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/