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

[amibroker] Re: Need some assistance with this system



PureBytes Links

Trading Reference Links

Hi all,

I am having trouble trying to make this code to work.  I'm trying to tell AB
that if entry1 or entry2 triggers, the other one will be cancel and it will
begin with the criteria that follows.  In simple math, I would this to
happen:

Assume LONG

if the Close crosses Entry1 or if entry 2 crosses the close, then begin:

Plot horizontal line for profit objective as RED
Plot horizontal line for risk as Blue

if Close crosses Risk , then go short.

I have the following code written but it is not doing what I want

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

TradeOpenNumber  = Param("1st Trade Open Number",0,0,1,.01);
ProfitTargetNumber  = Param("Profit Target Number",0,0,2,.01);
RiskNumber  = Param("Risk Number",0,0,2,.01);

TodayOpen = TimeFrameGetPrice( "O", inDaily, 0 );

entry1 = todayOpen + TradeOpenNumber ;

Long = Cross ( C, entry1) ;

entry2 = todayOpen - TradeOpenNumber ;

Short = Cross ( entry2, C ) ;

Sell1 = entry1 + ProfitTargetNumber;

Cover1 = entry2 - ProfitTargetNumber;

reverse_short = H - RiskNumber ; //round to lower 1/8

reverse_long = L + RiskNumber ; //round to higher 1/8

for( i = 1; i < BarCount; i++ ) {
    if ( Long [i] == 1 OR Short [i] == 1 ) {
    if (  Long [i] == 1 ) {
    Plot ( Sell1, "Profit for Long", colorOrange, styleLine ) ;
    Plot ( reverse_short, "Reversal", colorRed, styleLine ) ;
}

else {
    Plot ( Cover1, "Profit for Short", colorBlue, styleLine ) ;
    Plot ( reverse_long, "Reversal", colorGreen, styleLine ) ;
}
}
}