кто знает объясните пожалуйста.
MA1 = iMA(NULL,PERIOD_M15,per_MA1,2,MODE_SMMA,PRICE_CLOSE,0);
MA1_prew = iMA(NULL,PERIOD_M15,per_MA1,2,MODE_SMMA,PRICE_CLOSE,1);
MA2 = iMA(NULL,PERIOD_M15,per_MA2, 2,MODE_SMMA,PRICE_CLOSE,0);
MA3 = iMA(NULL,PERIOD_M15,per_MA3,2,MODE_SMMA,PRICE_CLOSE,0);
Можно.
А у тебя ж наверное условие типа: (обычное пересечение допустим)
shift_fast=-10
iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,1)>iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,1)
&& iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,2)<=iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,2)
Если так то конечно не будет ни одной сделки! У мувинга fast никогда на первых 10 барах не будет значения...
А у тебя ж наверное условие типа: (обычное пересечение допустим)
shift_fast=-10
iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,1)>iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,1)
&& iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,2)<=iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,2)
Если так то конечно не будет ни одной сделки! У мувинга fast никогда на первых 10 барах не будет значения...
спасибо попробую. В програмировании почти ничего не понимаю.
ВОТ ПОЖАЛУЙСТА
//---- input parameters
extern int TakeProfit_Buy = 200;
extern int TakeProfit_Sell = 200;
extern int StopLoss_Buy = 200;
extern int StopLoss_Sell = 200;
extern int TrailingStop = 0;
extern double Lots = 0.01;
extern int per_MA1 = 6;
//extern int per_SMA20 = 20;
//extern int per_SMA40 = 40;
extern int per_MA2 = 8;
extern int per_MA3 = 300;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if (Volume[0] > 1) return(0);
//----
// Объявляем переменные
int total, cnt, Buy=0, Sell=0;
double MA1, MA2,MA3,MA1_prew;
int err;
// Вычисляем начальные параметры индикаторов для поиска условий входа
MA1 = iMA(NULL,PERIOD_M15,per_MA1,0,MODE_SMMA,PRICE_OPEN,0);
//SMA20 = iMA(NULL,PERIOD_M30,per_SMA20,0,MODE_SMA,PRICE_MEDIAN,1);
MA1_prew = iMA(NULL,PERIOD_M15,per_MA1,0,MODE_SMMA,PRICE_OPEN,2);
//SMA40 = iMA(NULL,PERIOD_M30,per_SMA40,0,MODE_SMA,PRICE_MEDIAN,1);
MA2 = iMA(NULL,PERIOD_M15,per_MA2, 0,MODE_SMMA,PRICE_OPEN,0);
MA3 = iMA(NULL,PERIOD_M15,per_MA3,0,MODE_SMMA,PRICE_OPEN,0);
// проверим, есть ли ранее открытые позиции или ордеры?
total=OrdersTotal()-2;
// Проверка средств
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
//if(total<1)
// {
// Проверка условий для совершения сделки
if(Buy<1 && MA1>MA3 && (MA1-MA2)>=0.0001 && MA1_prew<MA2)
{
Print("BUY MA1 = ",MA1," MA2 = ", MA2," MA1_prew = ",MA1_prew);
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy *Point,"Покупаем",16384,0,Green);
//Sleep(3000);//10 секунд
RefreshRates();
//OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy *Point,"Покупаем",16384,0,Green);
//return(0);
}
if(Sell<1 && MA1<MA3 && (MA2-MA1)>=0.0001 && MA1_prew>MA2)
{
Print("SELL MA1 = ",MA1," MA2 = ", MA2," MA1_prew = ",MA1_prew);
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell *Point,Bid-TakeProfit_Sell *Point,"Продаем",16385,0,Red);
//Sleep(3000);//10 секунд
RefreshRates();
//OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell *Point,Bid-TakeProfit_Sell *Point,"Продаем",16385,0,Red);
//return(0);
}
// }
for(cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY)
{
// if(MA1<=MA2)
{
//OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
//Buy=0;
// return(0); // exit
}
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop) // Bid - цена покупки
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
//return(0);
}
}
}
}
if(OrderType()==OP_SELL)
{
//if(MA1>=MA2)
{
//OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
//Sell=0;
// return(0); // exit
}
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) // Ask - цена продажи
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
//return(0);
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//---- input parameters extern int TakeProfit_Buy = 200; extern int TakeProfit_Sell = 200; extern int StopLoss_Buy = 200; extern int StopLoss_Sell = 200; extern int TrailingStop = 0; extern double Lots = 0.01; extern int per_MA1 = 6; //extern int per_SMA20 = 20; //extern int per_SMA40 = 40; extern int per_MA2 = 8; extern int per_MA3 = 300; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (Volume[0] > 1) return(0); //---- // Объявляем переменные int total, cnt, Buy=0, Sell=0; double MA1, MA2,MA3,MA1_prew; int err; // Вычисляем начальные параметры индикаторов для поиска условий входа MA1 = iMA(NULL,PERIOD_M15,per_MA1,0,MODE_SMMA,PRICE_OPEN,0); //SMA20 = iMA(NULL,PERIOD_M30,per_SMA20,0,MODE_SMA,PRICE_MEDIAN,1); MA1_prew = iMA(NULL,PERIOD_M15,per_MA1,0,MODE_SMMA,PRICE_OPEN,2); //SMA40 = iMA(NULL,PERIOD_M30,per_SMA40,0,MODE_SMA,PRICE_MEDIAN,1); MA2 = iMA(NULL,PERIOD_M15,per_MA2, 0,MODE_SMMA,PRICE_OPEN,0); MA3 = iMA(NULL,PERIOD_M15,per_MA3,0,MODE_SMMA,PRICE_OPEN,0); // проверим, есть ли ранее открытые позиции или ордеры? total=OrdersTotal()-2; // Проверка средств if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } //if(total<1) // { // Проверка условий для совершения сделки if(Buy<1 && MA1>MA3 && (MA1-MA2)>=0.0001 && MA1_prew<MA2) { Print("BUY MA1 = ",MA1," MA2 = ", MA2," MA1_prew = ",MA1_prew); OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy *Point,"Покупаем",16384,0,Green); //Sleep(3000);//10 секунд RefreshRates(); //OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy *Point,"Покупаем",16384,0,Green); //return(0); } if(Sell<1 && MA1<MA3 && (MA2-MA1)>=0.0001 && MA1_prew>MA2) { Print("SELL MA1 = ",MA1," MA2 = ", MA2," MA1_prew = ",MA1_prew); OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell *Point,Bid-TakeProfit_Sell *Point,"Продаем",16385,0,Red); //Sleep(3000);//10 секунд RefreshRates(); //OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell *Point,Bid-TakeProfit_Sell *Point,"Продаем",16385,0,Red); //return(0); } // } for(cnt=total-1;cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUY) { // if(MA1<=MA2) { //OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position //Buy=0; // return(0); // exit } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) // Bid - цена покупки { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); //return(0); } } } } if(OrderType()==OP_SELL) { //if(MA1>=MA2) { //OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position //Sell=0; // return(0); // exit } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) // Ask - цена продажи { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); //return(0); } } } } } //---- return(0); }
Чё то поправки к коду я так и не увидел... И где BUY, SELL становяться >= 1
Если взять тот пример что я приводил c пересечением:
iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,1-shift_fast)>iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,1-shift_slow) && iMA(NULL,0,Ma_Fast_Period,shift_fast,method_fast,applied_price_fast,2-shift_fast)<=iMA(NULL,0,Ma_Slow_Period,shift_slow,method_slow,applied_price_slow,2-shift_slow)
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Вы принимаете политику сайта и условия использования
кто знает объясните пожалуйста.
MA1 = iMA(NULL,PERIOD_M15,per_MA1,2,MODE_SMMA,PRICE_CLOSE,0);
MA1_prew = iMA(NULL,PERIOD_M15,per_MA1,2,MODE_SMMA,PRICE_CLOSE,1);
MA2 = iMA(NULL,PERIOD_M15,per_MA2, 2,MODE_SMMA,PRICE_CLOSE,0);
MA3 = iMA(NULL,PERIOD_M15,per_MA3,2,MODE_SMMA,PRICE_CLOSE,0);