Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 292

 
What kind of Expert Advisor would you like to run on a real account?
 
Profitov:
What kind of Expert Advisor may I ask? What does the "Martin" tell me about the next one you would like to use on a real account?

I do not know what kind of "Martin"))) I do not know about the "Martin". No, not yet for the real account, not for the demo, but I want to use the demo account of the same brokerage company that may be used for the real account later.

 
SpikeOne:

Guys, can someone please describe what is going on and show the place where orders are closing in the +, and opening a new series.

Andrei, no offence, but this absurdity belongs in the Annals!
 

Greetings all! I'm asking for help in solving an interesting problem. I have an EA, the feature of which is that after getting a profit the next trades from 1 to 4 are closed on stop loss, then profit again. The Expert Advisor opens trades based on the indicator signal. To exclude profitable trades following after the profit, one should skip the signals generated by the indicator, i.e. not close deals (1,2,3,4) after getting a profit. The Sig function is available for this purpose. However, I think I wrote this function wrong because the EA does not open orders with it and everything is working very well without it. Please, advise the smart people where I have made a mistake.

Yes, signal is number of signals after profit and pynkt is profit size in pips.

I would be grateful for the help.

 
void CheckForOpen()
{
   int ticket, STOPLEVEL;
   double Price, SL, TP; 
   STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);


   double MA1Low = NormalizeDouble (iMA(NULL,0,MA_Period_2,MA_Shift_2,MA_Method_2,0,1), Digits); 
   double MA2High = NormalizeDouble (iMA(NULL,0,MA_Period_2,MA_Shift_2,MA_Method_2,1,1), Digits);
   
 
  
   if(Volume[0]>1) return;

    // продажа
   if (Open[1]>Close[1] && Open[1] > MA1Low && Close[1] < MA1Low)
   
{
      if(Pro(1,100))

   {
       ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"Pattern_1",1000,0,Red);
      return;
    }
   
  }  
//---- buy conditions
   // покупка
  if (Open[1]<Close[1] && Open[1] < MA2High && Close[1] > MA2High)
 
 { 
   if(Pro(1,100))
   {
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"Pattern_1",1000,0,Blue);
      return;
   }       
   }
}
 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool Sig(int signal,int pynkt)
 {
  static int cnt = 0;
  static datetime tm;
  if(Time[0] == tm) return(false);
  tm = Time[0];
  if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) == true)
   {
    cnt = cnt + 1;
    if(OrderType() == OP_BUY && OrderClosePrice() - OrderOpenPrice() < pynkt*Point) cnt = 0;
    if(OrderType() == OP_SELL && OrderOpenPrice() - OrderClosePrice() < pynkt*Point) cnt = 0;
    if(cnt >= signal) return(true);
   }
  return(false);
 }
//+------------------------------------------------------------------+
 
Help me out, the EA does not compile
//ПАРАМЕТРЫ ОТКРЫТИЯ ДЛИННОЙ ПОЗИЦИИ

if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)>100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)>-100 
{
if((NumberOfBarOpenLastPos()>0||NumberOfBarOpenLastPos()==-1)&&(NumberOfBarCloseLastPos()>0||NumberOfBarCloseLastPos()==-1))
{ 
Opn_B=true;
//Cls_S=true;
}
}
 //ПАРАМЕТРЫ ОТКРЫТИЯ короткой ПОЗИЦИИ    
if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100
{
if((NumberOfBarOpenLastPos()>0||NumberOfBarOpenLastPos()==-1)&&(NumberOfBarCloseLastPos()>0||NumberOfBarCloseLastPos()==-1))
{
Opn_S=true; 
//Cls_B=true;   
}  
}


if(Tip==0){
           if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(SL<Bid-Point*TrailingStop)
                    {
                     OrderModify(Ticket,OrderOpenPrice(),Bid-Point*TrailingStop,TP,0,Green);
                     //return(0);
                    }
                 }
              }
}

if(Tip==1){
           if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if(SL>Ask+Point*TrailingStop)
                    {
                     OrderModify(Ticket,OrderOpenPrice(),Ask+Point*TrailingStop,TP,0,Red);
                    // return(0);
                    }
                 }
              }
}


   // Закрытие ордеров
   while(true)                                  // Цикл закрытия орд.
     {
//длинной
//if (iRSI(NULL,0,14,PRICE_CLOSE,0)<30&&iRSI(NULL,0,14,PRICE_CLOSE,1)>30){
 if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100 {  
      if (Tip==0)                // Открыт ордер Buy..
        {                                       //и есть критерий закр
         Alert("Попытка закрыть Buy ",Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose(Ticket,Lot,Bid,2);      // Закрытие Buy
         if (Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Buy ",Ticket);
            break;                              // Выход из цикла закр
           }
                           
            
         if (Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }
        }

// короткой       
if (Close[NULL]){
      if (Tip==1)                // Открыт ордер Sell..
        {                                       // и есть критерий закр
         Alert("Попытка закрыть Sell ",Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose(Ticket,Lot,Ask,2);      // Закрытие Sell
         if (Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Sell ",Ticket);
            break;                              // Выход из цикла закр
           }
                  
           
         if (Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }
        }
      break;                                    // Выход из while
     }

 
niformalka:
help me out, the EA doesn't compile.

... and what language rules did you sculpt it according to?! For example:

if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)>100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)>-100 
{

:)

 
niformalka:
help me out, the EA doesn't compile

Double click on the red circle signalling a compilation error and you will see the same circle to the left on the line where to look for the error! You can't see your circle from here!

And delete your post as I deleted mine with your sheet!

 
SpikeOne:

you have the year 2014
Would love a comprehensive answer! Going to make this brand a top seller.
 
niformalka:

Guys, help me find a bug, the EA does not compile, I've already racked my brains over it, presumably an error in the long/short position opening and closing lines


//OPEN LONG POSITION PARAMETER

if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)>100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)>-100
{
if((NumberOfBarOpenLastPos()>0||NumberOfBarOpenLastPos()==-1)&&(NumberOfBarCloseLastPos()>0||NumberOfBarCloseLastPos()==-1))
{
Opn_B=true;
//Cls_S=true;
}
}
//Short POSITION OPENING PARAMETERS
if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100
{
if((NumberOfBarOpenLastPos()>0||NumberOfBarOpenLastPos()==-1)&&(NumberOfBarCloseLastPos()>0||NumberOfBarCloseLastPos()==-1))
{
Opn_S=true;
//Cls_B=true;
}
}


if(Tip==0){
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(SL<Bid-Point*TrailingStop)
{
OrderModify(Ticket,OrderOpenPrice(),Bid-Point*TrailingStop,TP,0,Green);
//return(0);
}
}
}
}

if(Tip==1){
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(SL>Ask+Point*TrailingStop)
{
OrderModify(Ticket,OrderOpenPrice(),Ask+Point*TrailingStop,TP,0,Red);
// { return(0);
}
}
}
}


// Close orders
while(true) // Close order loop
{
//long
//if(iRSI(NULL,0,14,PRICE_CLOSE,0)<30&iRSI(NULL,0,14,PRICE_CLOSE,1)>30){
if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100 {
if (Tip==0) //Open Buy order
{ //and there is a close criterion
Alert("Trying to close Buy ",Ticket,". waiting for reply...);
RefreshRates(); // Refresh data
Ans=OrderClose(Ticket,Lot,Bid,2); // Close Buy
if (Ans==true) // It worked :)
{
Alert ("Closed Buy order ",Ticket;)
break; // Exit from the close loop
}


if (Fun_Error(GetLastError())==1) // Error handling
continue; // retry
return; // Exit from start()
}
}

// short
if (Close[NULL]){
if (Tip==1) //Open Sell order.
{ // there is a close criterion
Alert("Attempting to close Sell ",Ticket,";)
RefreshRates(); // Update data
Ans=OrderClose(Ticket,Lot,Ask,2); // Close Sell
if (Ans==true) // It worked :)
{
Alert ("Sell order closed ",Ticket;)
break; // Exit from the close loop
}


if (Fun_Error(GetLastError())==1) // Error handling
continue; // retry
return; // Exit from start()
}
}
break; // Exit while
}



The only thing the compiler can't do is declare variables.
 
oDin48:

Guys, please advise a good DC for EA trading?


Share the information, please, because what's the point of writing an owl without having normal DCs to work with.
Reason: