[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 795

 
obla4ko:
You should not think like a stick - it's a very subtle thing :))), virtual, I would say, and it should naturally react to fraud in history. If it did not react to erasures, then I can imagine how slow it would be in real life - 100 quid a year for 10K - at best... Well, it's easier to keep the money in the bank - they give 3-6 percent!)

))) Of course it's easier! Who's to say... // And who said it would be easy? )))

One way out - go to the stock exchange. This kind of crap doesn't happen there in principle. But this way... For all the - how shall I put it - um... ... oddities you can work on Forex, too.

The best way is, of course, to test it on the real account. If the principles laid down in the Expert Advisor are correct (and this can exactly be checked in the tester), then, putting force majeure measures on a real account, the trade will be good+. Maybe not at +++++++ like in the tester, but still...))

By the way, cutting gaps, which make indicators go crazy, from quote flow helps a lot. You can look in my codes - Kill Gap.

 

Techno:
obla4ko, создайте переменную типа datetime x, и пусть это будет время открытие бара, на котором произошел стоплосс. А в условии открытия поставте, что (Time[0]!=x). При этом x должно обновляться при новом сработавшем стоплосе. Это первый вариант. И второй как я уже в третий раз пишу, после срабатывания стопа включить ожидание 1 бар, это будет совершенно тоже самое, не логично разве?

I have the part of the code responsible for opening a position posted in my last post. Could you please put what you said here into it - as they say "better seen once than...." :)
 

Hello!!!

On page 71 of this thread, granit77 wrote a very interesting piece!

Извините, что встреваю, поделюсь ламерским способом удобной записи множества условий. При наладке легко добавлять/убирать, не заботясь о скобках, и все наглядно. 
if (true
    && StochK_0<StochD_1
    && StochD_1 > 80 
    && cci_0 < cci_1    
    && cci_0 > 100 
    //&& .... а это я пока убрал     
   )

here is a sample and tried to do something

if(((Sto_0>Sto_1&&Sto_0< 20)&&(OsMA_0>OsMA_1&&OsMA_0<-P)&&(Macd_0>Macd_1&&Macd_0<-N)))
// это основа
if(true
      &&Sto_0>Sto_1&&Sto_0< 20
      &&OsMA_0>OsMA_1&&OsMA_0<-P
      &&Macd_0>Macd_1&&Macd_0<-N
      )//а это то что получилось

i'm asking because it's so unusual.....

 

Why does this work and count correctly increasing the value of a variable by 10 per cent:

TStartS = MathRound(TStartS+TStartS*0.1);

... but this one doesn't:

TStartS = MathRound(TStartS+TStartS/100*PercentTakePr); // где PercentTakePr - внешняя переменная, равна 10, 20, 30, и т.д. ...
what's the difference, I don't know...
 
artmedia70:

Why does this work and count correctly increasing the value of a variable by 10 per cent:

... but this one doesn't:

what's the difference, I don't know...





or maybe it's like this.

TStartS = MathRound(TStartS+(TStartS/100*PercentTakePr)); 
 

What's the problem? You just have to break the string into substrings, without changing the content. Everything will work the same way, but it's easier to read and edit, just comment unnecessary lines.

It turns out the pros have been writing this way for a long time, even formatting it better, so I invented the bicycle. :))

if (true              &&
    StochK_0<StochD_1 && 
    StochD_1 > 80     &&  
    && cci_0 < cci_1  &&   
    && cci_0 > 100 
   )

//((Sto_0>Sto_1&&Sto_0< 20)&&(OsMA_0>OsMA_1&&OsMA_0<-P)&&(Macd_0>Macd_1&&Macd_0<-N))
// Ваш вариант вот так будет выглядеть наиболее прозрачно, на мой взгляд
if (true                         &&
    (Sto_0 >Sto_1  && Sto_0 <20) &&
    (OsMA_0>OsMA_1 && OsMA_0<-P) &&
    (Macd_0>Macd_1 && Macd_0<-N)  
   ) 
 
artmedia70:

Why does this work and count correctly increasing the value of a variable by 10 per cent:

... but this one doesn't:

What's the difference - I don't understand...





0.1 is double and 100 is int.

Look up type conversion in the textbook.

 
Svinozavr:

0.1 is double and 100 is int.

Look up type conversion in the textbook.

So I have ALL variables there int... It turns out that ... ouch... screw it ... keep digging...

That's how it works:

LastTakeProfitS = MathRound(LastTakeProfitS+LastTakeProfitS/100*PercentTakePr);
... and if you stick another variable of the same type in here, it doesn't work... It's been blowing my mind this morning...
 
obla4ko:

I have the part of the code responsible for opening a position posted in my last post. Could you please put what you said here into it - as the saying goes "better seen once than...." :)

Here is a schematic. Not checked, but should work, missing parts must be added from the original code. Red marked the number which change will increase waiting, the number 2 means that one candle waiting. If you need 2 candles waiting put three, etc.

bool work=1;int tick;datetime t;
int start()
{
  if(!work){if(t!=iTime(NULL,0,1)){t=iTime(NULL,0,1);tick++;}}
  if(tick==2){work=1;tick=0;} 
   
   time();
   if(OrdersTotal()==0)CheckForOpen();
  //-- code
}
//----
void CheckForOpen()
{
   double ma;
   int    res;
    
   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);

   if(work && Open[1]>ma && Close[1]<ma)  
     {
      res=OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Bid+Stoploss*Point,Bid-Takeprofit*Point,"",MAGICMA,0,Red);
      return;
     }

   if(work && Open[1]<ma && Close[1]>ma)  
     {
      res=OrderSend(Symbol(),OP_BUY,Lots,Ask,30,Ask-Stoploss*Point,Ask+Takeprofit*Point,"",MAGICMA,0,Blue);
      return;
     }

}
//----
void time()
{
static datetime time;
    
  if(OrdersHistoryTotal()==0)return;
  for(int i=0;i<OrdersHistoryTotal();i++)
       {
       OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
         if(OrderCloseTime()>time && OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
            {
            time=OrderCloseTime();
            if(OrderProfit()<0)work=0;
            }
       }    
   
}
 
artmedia70:

So I have ALL variables there int... It turns out that ... ouch... screw it ... keep digging...

This one works:

...but if you just plug in another variable of the same type, it doesn't work... It blew my mind this morning...


It's... I found it... Instead of 100, it's 100.0. I'd kill you...
Reason: