Originally Posted by
;
int start ()
{
int count;
if (Barslt; 100) {Print (бары меньше 100); Возвращение (0); }
всего = OrdersTotal ();
if (trend! = 0) {last_trend = trend; }
Тенденция = MACD_Direction ();
Сила = trend_strength ();
if (pending_timegt; 0) last_pending_time = pending_time;
для (Count = 0; countlt, общий, граф ) Gt;
{
OrderSelect (count, SELECT_BY_POS, MODE_TRADES);
if (OrderType () lt; = OP_SELL OrderSymbol () == Symbol ())
{
if (OrderType () == OP_BUY find_highest)
{
trailing_stop (1);
if (Close [0] gt; = OrderOpenPrice () Point * 5) {pending_time = 0; revival_attempts = 0; opposite_trend_duration = 0; opp_trend_period = 0; }
if (Close [0] lt; orderopenprice () point * 5) {= pending_time = last_loss = OrderOpenPrice () Point * 5-Close [0]; opp_trend_period = 0;} л; brgt; if (forcelt; = - 0,95 * MACD_level) opp_trend_period ;
if (best_deal () gt; 0) ClosePending ();
}
иначе если (OrderType () == OP_SELL find_lowest)
{
trailing_stop (2);
if (Close [0] lt; = OrderOpenPrice () - Точка * 5) {pending_time = 0; revival_attempts = 0; opp_trend_period = 0; }
if (Close [0] gt; OrderOpenPrice () - Point * 5) pending_time ;
if (forcegt; = 0,95 * MACD_level) opp_trend_period ;
if (best_deal () gt; 0) ClosePending ();
}
}
}
if (trendgt; 0 stronggt; = 0,95 * MACD_level) {buy_flag = true; sell_flag = ложь; last_trend = тренд; }
if (trendlt; 0 forcelt; = - 0,95 * MACD_level) {sell_flag = true; buy_flag = ложь; last_trend = тренд; }
if ((sell_flag == true || buy_flag == true) всего == 0 тренд! = 0)
{
if (buy_flag == true) do_order (1);
if (sell_flag == true) do_order (2);
}
}