//+------------------------------------------------------------------+ //| 666.mq4 | //| Crazy | //| | //+------------------------------------------------------------------+ #property copyright "Crazy " #property link "" //---- input parameters //---- input parameters extern double TakeProfit = 50; extern double Lots = 0.1; extern double StopLoss = 11; extern double FreeMargin = 2500; extern double MathLots = 900; extern double ModStop = 25; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int cnt, ticket, total,TotalOpenOrders,Commentary; int napr; double high1 = iHigh(NULL,0,1); //Âåðõíÿÿ öåíà ïðîøëîãî ïåðèîäà double low1 = iLow(NULL,0,1); //Íèæíÿÿ öåíà ïðîøëîãî ïåðèîäà double open1 = iOpen(NULL,0,1); //Öåíà îòêðûòèÿ ïðîøëîãî ïåðèîäà double close1 = iClose(NULL,0,1);//Âåðõíÿÿ çàêðûòèÿ ïðîøëîãî ïåðèîäà double high2 = iHigh(NULL,0,2); //Âåðõíÿÿ öåíà ïîçàïðîøëîãî ïåðèîäà double low2 = iLow(NULL,0,2); //Íèæíÿÿ öåíà ïîçàïðîøëîãî ïåðèîäà double open2 = iOpen(NULL,0,2); //Öåíà îòêðûòèÿ ïîçàïðîøëîãî ïåðèîäà double close2 = iClose(NULL,0,2);//Âåðõíÿÿ çàêðûòèÿ ïîçàïðîøëîãî ïåðèîäà if (open1>close1)napr = 1; else napr = 0; //Comment(high1,"\n",low1,"\n",open1,"\n",close1); //---- // ñ÷èòàåì êîëâî îòêðûòûõ îðäåðîâ total=OrdersTotal(); TotalOpenOrders = 0; for(cnt=0;cnt<total;cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) == true) { if (OrderSymbol()==Symbol()) { TotalOpenOrders = TotalOpenOrders+1; if (OrderType( ) == 0) { //Comment("Ñòîèò Áàé"); //Comment(OrderTakeProfit(),"|",Bid,"|", OrderTakeProfit()-Bid); if ((OrderTakeProfit()-Bid)<=ModStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-StopLoss*Point,Bid+TakeProfit*Point,0,CLR_NONE); } } else { // Comment(OrderTakeProfit(),"|",Ask,"|", Ask-OrderTakeProfit()); if ((Ask-OrderTakeProfit())<=ModStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+StopLoss*Point,Ask-TakeProfit*Point,0,CLR_NONE); //Comment("Èçìåíèòü"); // Comment("Ñòîèò Ñåëë"); } } }//ÊîíåöÅñëè ýòîò ñèìâîë }//ÊîíåöÅñëè âûáðàí }//ÊîíåöÖèêëà if (TotalOpenOrders < 1) { /* if (AccountEquity()< FreeMargin) { Lots = 0.1; } else Lots = (MathRound( AccountEquity()/MathLots)/ 10); */ if (napr == 0) { OrderSend(Symbol(), OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,NULL,0,0,CLR_NONE); } if (napr == 1) { OrderSend(Symbol(), OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,NULL,0,0,CLR_NONE); } } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains open prices of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached
Other Features: