[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 71

 
DhP:
The MagicNumber does not change in this case, unless it is provided by the EA code.

Thank you all!
 
Roman.:


Solution:

For buy (sell - by analogy):

1. MA fracture - get MA values on bars 3, 2 and 1 - compare. If MA values on bars 3>2 and 2<1, it is a break.

2. then - fractal - penetration - a signal to make a deal

As far as the enumeration of MA is concerned - place it in external (optimizable) variables:

Period_MA (you can set from 2 to 240 with step 2), MODE - (method of calculation of MA - range of changes from 0 to 3 step 1), PRICE_TYPE - (price constant - range of changes from 0 to 6 step 1), I heard that when working within the day MA count on the average values (closing price is not important), when working on the day candles MA count on the closing prices of the days.

PERIOD - you change it manually with each subsequent optimization - 1,5,15,30,60,240...

Press F1 on the iMA - carefully read everything there again.

And of course optimize TP and Stop Loss as usual.

P.S. Don't forget to write an information on the results of the tests... :-)))

Tests results for TF=1 min did not yield profitable variants, even if we optimize the EA once a day.
 
DhP:
When a position is partially closed, you can change the magik. I'm sure you can easily write this.

You probably have knowledge that is not available to the mql-community or you just don't understand the question or you are naively deluded that the OrderClose function changes the magik.

 
gince:

I understand that I don't have an initial flag[i+1] setting. If so, where and how do I do it ?

If I set 1, then when I start the indicator, it (the indicator) will wait for the change.

The correct way to do it is this:

if ((flag[i]==1 || flag[i]==0) && условие продажи)
with the condition that uninitialised flag =0 (or take EMPTY_VALUE....)
 
sergeev:

the right thing to do is this:

With the condition that uninitialised flag =0 (or take EMPTY_VALUE....)

Thank you all. I did what I wanted to do.

 
volshebnik:
Test results on TF=1 min did not yield profitable options, even if you optimise the EA once a day.

The lower the TF, the higher the noise...
 
Roman.:

The lower the TF, the higher the noise...
Yes, but if the strategy is correct, it should, it seems to me, work on any TF, just with different parameters. Tests result on TF=5 min did not give profitable options either.
 
volshebnik:
Yes, but if the strategy is correct, it should, it seems to me, work on any TF, just with different parameters. The result of the tests on TF=5 min did not give any profitable options either.

The strategy is correct there. I am drunk now. I am having a rest.
 
sergeev:

you still have an error in your code.

Remember: Stops and Takeovers in pending orders are not based on the current price but on the opening price of the order.



Special thanks and respect to you :)))))

Corrected errors (hopefully all of them now :)) ) + added limiters. It will be very useful for those who really need to assign Magic number to placed orders.

Enjoy it!

#property copyright "Copyright © 2010 - 2011, Хлыстов Владимир, в редакции AMRo"
#property link      "cmillion@narod.ru, nemo811@mail.ru"
#property show_inputs
/*
Иногда требуется помочь советнику добавить ордер, но чтобы советник его принял за свой
необходим Magic номер. Для выставления ордера с таким номером и предназначен этот скрипт.
Возможна одновременная установка до 6 типов ордеров. При сбоях связи или резком движении цены
будет выполнено 10 попыток выставления ордера, после чего скрипт закончит работу.
*/
//--------------------------------------------------------------------
extern int     Magic       = 0;        //уникальный номер ордера
extern bool    BUY         = false;    //открыть ордер BUY
extern bool    BUY_STOP    = false;    //поставить ордер BUY STOP
extern bool    BUY_LIMIT   = false;    //поставить ордер BUY LIMIT
extern bool    SELL        = false;    //открыть ордер SELL
extern bool    SELL_STOP   = false;    //поставить ордер SELL STOP
extern bool    SELL_LIMIT  = false;    //поставить ордер SELL LIMIT
extern double  Lot         = 0.1;      //объем ордера
extern int     takeprofit  = 0;        //уровень выставления TP, если 0, то TP не выставляется
extern int     stoploss    = 0;        //уровень выставления SL, если 0, то SL не выставляется
extern int     DistanceSet = 40;       //расстояние от рынка для отложенника
extern int     slippage    = 3;        //максимально допустимое отклонение цены для рыночных ордеров
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
   if (BUY)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy");
   }
   if (SELL)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell");
   }
   if (BUY_STOP)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask + DistanceSet*Point - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy Stop");
   }
   if (SELL_STOP)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid - DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid - DistanceSet*Point + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell Stop");
   }
   if (BUY_LIMIT)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask - DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - DistanceSet*Point - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy Limit");
   }
   if (SELL_LIMIT)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid + DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid + DistanceSet*Point + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell Limit");
   }
return(0);
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
   int error,err;
   while (true)
   {  error=true;
      if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0);
      if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,"",Magic,0);
      if (ord=="Buy Stop" ) error=OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
      if (ord=="Sell Stop") error=OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
      if (ord=="Buy Limit" ) error=OrderSend(Symbol(),OP_BUYLIMIT, Lot,NormalizeDouble(Ask - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
      if (ord=="Sell Limit") error=OrderSend(Symbol(),OP_SELLLIMIT,Lot,NormalizeDouble(Bid + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
      if (error==-1) //неудачная попытка
      {  
         ShowERROR();
         err++;Sleep(2000);RefreshRates();
      }
      if (error || err >10) return;
   }
return;
}                  
//--------------------------------------------------------------------
void ShowERROR()
{
   int err=GetLastError();
   switch ( err )
   {                  
      case 1:   return;
      case 2:   Alert("Нет связи с торговым сервером ",Symbol());return;
      case 3:   Alert("Error неправильные параметры ",Symbol());return;
      case 130: Alert("Error близкие стопы   Ticket ",Symbol());return;
      case 134: Alert("Недостаточно денег   ",Symbol());return;
      case 146: Alert("Error Подсистема торговли занята ",Symbol());return;
      case 129: Alert("Error Неправильная цена ",Symbol());return;
      case 131: Alert("Error Неправильный объем ",Symbol());return;
      case 4200:Alert("Error Объект уже существует ",Symbol());return;
      default:  Alert("Error  " ,err," ",Symbol());return;
   }
}
//--------------------------------------------------------------------
 
Roman.:

there's a true strangia there. I'm high as a kite right now. I'm resting.
Same on TF = 15 min. Can't see any "fidelity" in this strategy yet, may yet show up ahead. (Have a nice rest))