[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 243

 
costy_ >> :

Should go to buy when opening is higher than ma1.

I understand that "tumblr" in || as I do not know how to denote for example "if" (ma1>ma2&ma1>Open[1] "or" ma1>ma3&&ma1>Open[1]) "then" Open BAY();


You can see from the graph that not all conditions are met!!!


Tried through else on one candle 53 purchases.


What other way to implement logic?


There are just a huge number of errors in your piece of code.

Describing them all and explaining why it is so and not otherwise.... I don't have that much time.

The only thing I will correct for now:

if (( ma1> ma2 && ma1> ma3 && Open[1]> ma1) || 
    ( ma2> ma1 && ma2> ma3 && Open[1]> ma1) ||
    ( ma3> ma1 && ma3> ma2 && Open[1]> ma1)
  )
  OpenBuy();
Maybe I'll give you more tips when I have time ....



 
Thanks. Got it.
if (( ma1> ma2 && ma1> ma3  && Open[1]> ma1) || 
    ( ma2> ma1 && ma2> ma3  && Open[1]> ma1) ||
    ( ma3> ma1 && ma3> ma2  && Open[1]> ma1)
   )
    OpenBuy();

but I have to.

if ( ma1> ma2 && ma1> ma3 && Open[1]> ma1)
OpenBuy();
if ( ma2> ma1 && ma2> ma3 && Open[1]> ma1)
OpenBuy();
if ( ma3> ma1 && ma3> ma2 && Open[1]> ma1)
OpenBuy();
 
costy_ >> :

>> and I have to

Same thing, only the first option is shorter.

 
MrSoros >> :

Same thing, only the first option is shorter.

Unfortunately the first option didn't work correctly on the graph (it's all weird).

First of course more beautiful and the logic is like that, it is like first addition then multiplication. =))

 
MrSoros >> :

The signs are all right.

The idea itself (CCI closing), from my point of view - not ahchy....

I've been through this before...

But it's already a matter of strategy.

>> as many traders, so many strategies.


No, that's not how the algorithm works, now it closes on CCI if the profit is more than 10pp, and I need exactly the level of 10pp profit only there that would close on klose, if the profit is more than 10pp then it should not close on CCI. Right now it closes at CCI if the profit value is more than 10pp (

The very meaning of the algorithm in this function is different, there is a profit level of 10pp - that is a virtual profit, fixed by the clause in the direction of the SSI indicator. When the price goes in profit it always passes this level as SSI looks right, then having passed this level the price sometimes gives a reverse move back to the initial state, or change of the trend direction, - in this case SSI always looks in the other direction, and when passing in the opposite direction at 10pp the order is fixed, as SSI will look in the opposite direction.

  if (OrderType() == OP_BUY && cci_0< cci_1 && Bid-OrderOpenPrice() >= Point* profit) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
  if (OrderType() == OP_SELL && cci_0> cci_1 && OrderOpenPrice() - Ask >= Point* profit) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);

  

  cci_0< cci_1 && Bid-OrderOpenPrice() == Point* profit // может вот так? - так вообще не работает(
 

Hello.

See if the lot size is calculated correctly as a percentage of the balance:

//расчёт размера лота
double Lots()
   {
   double ls=MarketInfo(Symbol(),MODE_MINLOT)+MarketInfo(Symbol(),MODE_LOTSTEP)*MathFloor(( procentdepo*AccountBalance()/100000-MarketInfo(Symbol(),MODE_MINLOT))/MarketInfo(Symbol(),MODE_LOTSTEP));
     if( ls>MarketInfo(Symbol(),MODE_MAXLOT))   { ls=MarketInfo(Symbol(),MODE_MAXLOT); }
     if( ls<MarketInfo(Symbol(),MODE_MINLOT))   { ls=MarketInfo(Symbol(),MODE_MINLOT); }
   return( ls);
   }

where procentdepo is % of the deposit

 
Piboli >> :

Hello.

See if the lot size is calculated correctly as a percentage of the balance:

where procentdepo is % of the deposit.

Do this.

extern double PercentLots  = 0.5;// внешние переменные


//то что ниже закиньте в конец кода
double GetLots() 
{
double minlot = MarketInfo(Symbol(), MODE_MINLOT);
double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);

if( PercentLots!=0)
 {
   double lot = NormalizeDouble(AccountBalance() * PercentLots  /1000.0 / 100.0, 2);
   if( lot < minlot) lot = minlot;
   if( lot > maxlot) lot = maxlot;
  }
  else lot= Lots; 
  return( lot);
  }  

//GetLots() - вставьте в ticket=OrderSend(Symbol(),OP_BUY,GetLots(),Ask,3,stop,Ask+Takeprofit*Point,"",MagicNumber,0,Green);
 
Piboli >> :

Hello.

Check if the lot size is calculated correctly as a percentage of the balance:

where procentdepo is % of deposit

Better yet, use this lot optimization function, here works MM if there will be unprofitable trades, then the lot will be reduced to the initial one.

//внешние переменные
extern double Lots = 0.1;          //стартовый лот до баланса 500
extern double MaximumRisk = 0.1;   //увеличение лота на каждые 500 баланса
extern double DecreaseFactor = 3.0;//уменьшение лота при серии убыточных позиций


//то что ниже  закиньте перед стартом
double LotsOptimized() {
       double lot = Lots;
       int orders = OrdersHistoryTotal();
       int losses = 0;
       lot = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 500.0, 2);
       if ( DecreaseFactor > 0.0) {
for (int i = orders - 1; i >= 0; i--) {
       if (OrderSelect( i, SELECT_BY_POS, MODE_HISTORY) == FALSE) {
       Print("Error in history!");
       break;
       }
if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;
if (OrderProfit() > 0.0) break;
if (OrderProfit() < 0.0) losses++;
}
if ( losses > 1) lot = NormalizeDouble( lot - lot * losses / DecreaseFactor, 2);
}
if ( lot < 0.1) lot = 0.1;
if ( lot > 1000.0) lot = 1000;
return ( lot);}

int start(){//старт

LotsOptimized() -- вставьте в ticket=OrderSend(Symbol(),OP_BUY, LotsOptimized(),Ask,3, stop,Ask+ Takeprofit*Point,"", MagicNumber,0,Green);
 
Only the previous two posts don't take into account the step change of the lot. Unfortunately.
 
Vinin >> :
Only the previous two posts don't take into account the step of lot change. >> Unfortunately.

Can I do, if I understand the step correctly, how much of the balance will be added to the lot?

Or do you mean to have a constant curve of lot increase, but I don't see the point in such a progression.

extern double balans = 500; //шаг баланса

lot = NormalizeDouble(AccountFreeMargin() * MaximumRisk / balans, 1);
Reason: