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

Re: [amibroker] Re: Need some assistance with this system



PureBytes Links

Trading Reference Links

thanks Terry


I was able to make it work but there is something wrong in the exploration
and addcolumn.  Here is the code and the problem is highlighted in RED
below:

Many thanks in advance,

Tony

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

TradeOpenNumber_1  = Param("1st Trade Open Number",0.41,0,1,.01);
ProfitTargetNumber_1  = Param("1st Profit Target Number",.68,0,2,.01);
RiskNumber_1  = Param("1st Risk Number",.81,0,2,.01);

TradeOpenNumber_2  = Param("2nd Trade Open Number",0.5,0,1,.01);
ProfitTargetNumber_2  = Param("2nd Profit Target Number",.83,0,2,.01);
RiskNumber_2  = Param("2nd Risk Number",.99,0,2,.01);

TradeOpenNumber_3  = Param("3rd Trade Open Number",0.85,0,1,.01);
ProfitTargetNumber_3  = Param("3rd Profit Target Number",1.41,0,2,.01);
RiskNumber_3  = Param("3rd Risk Number",1.7,0,2,.01);

MarketHours = TimeNum()>=92900 AND TimeNum()<=160000;

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

TodayHigh = TimeFrameGetPrice( "H", inDaily, 0 );

TodayLow = TimeFrameGetPrice( "L", inDaily, 0 );

entry1 = todayOpen + TradeOpenNumber_1 ;
entry2 = todayOpen + TradeOpenNumber_2 ;
entry3 = todayOpen + TradeOpenNumber_3 ;
entrytotal = entry1 OR entry2 OR entry3 ;

Long1 = Cross ( C, entry1) AND Name() == "YHOO" ;
Long2 = Cross ( C, entry2) AND Name() == "MTG" ;
Long3 = Cross ( C, entry3) AND Name() == "SLB" ;
Longtotal = Long1 OR Long2 OR Long3 ;

entry1b = todayOpen - TradeOpenNumber_1 ;
entry2b = todayOpen - TradeOpenNumber_2 ;
entry3b = todayOpen - TradeOpenNumber_3 ;
entrybtotal = entry1b OR entry2b OR entry3b ;

Short1 = Cross ( entry1b, C ) AND Name () == "YHOO" ;
Short2 = Cross ( entry2b, C ) AND Name () == "MTG" ;
Short3 = Cross ( entry3b, C ) AND Name () == "SLB" ;
Shorttotal = Short1 OR Short2 OR Short3 ;

Sell1 = entry1 + ProfitTargetNumber_1;
Sell2 = entry2 + ProfitTargetNumber_2;
Sell3 = entry3 + ProfitTargetNumber_3;
Selltotal = Sell1 OR Sell2 OR Sell3 ;

Cover1 = entry1b - ProfitTargetNumber_1;
Cover2 = entry2b - ProfitTargetNumber_2;
Cover3 = entry3b - ProfitTargetNumber_3;
Covertotal = Cover1 OR Cover2 OR Cover3;

reverse_short1 = TodayHigh - RiskNumber_1 ; //round to lower 1/8
reverse_short2 = TodayHigh - RiskNumber_2 ;
reverse_short3 = TodayHigh - RiskNumber_3 ;
reverse_short_total = reverse_short1 OR reverse_short2 OR reverse_short3 ;

reverse_long1 = TodayLow + RiskNumber_1 ; //round to higher 1/8
reverse_long2 = TodayLow + RiskNumber_2 ;
reverse_long3 = TodayLow + RiskNumber_3 ;
reverse_long_total = reverse_long1 OR reverse_long2 OR reverse_long3 ;

entries = Long1 OR Long2 OR Long3 OR Short1 OR Short2 OR Short3 ;

exit1 = IIf( Long1 , Sell1, IIf( Short1, Cover1, 0 ));
exit2 = IIf( Long2 , Sell2, IIf( Short2, Cover2, 0 ));
exit3 = IIf( Long3 , Sell3, IIf( Short3, Cover3, 0 ));

Filter = entries ;

AddColumn (TodayOpen, "Open", 1.2) ;
AddColumn (TodayLow, "Low", 1.2) ;
AddColumn (entrytotal, "Long", 1.2, IIf ( longtotal, colorBlue, 0) )
;//Whenever
I use "entrytotal", it returns "1" instead of a numerical value.
AddColumn (entry3b, "Short", 1.2, IIf ( Short3, colorRed, 0 ) ) ;//This
returns the correct numerical value for stock3 but I would like the column
to return values for Stock1 or Stock2 or Stock3.
AddColumn (IIf (Long3, Sell3, IIf (Short3, Cover3, 0)), "Profit Target" ,
1.2) ;
AddColumn (IIf (C>entry3, reverse_short3, IIf (Short3, reverse_long3, 0)),
"Reversal", 1.2 ) ;