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

 

I'm facing a problem with the clause, can you tell me how to implement the CCI condition in the function.

A condition must be set and the order must be closed at the 10pp profit level.

1) If CCI is looking down, at 10pp profit level we close a buy order.

2) Sell - similar.

extern bool ClosePips   = true;//использовать закрытие ордера при профите 10пп по условиям ССИ
extern double profit    = 10.0;//профит по клозе

int start(){
double cci_0 = iCCI(NULL, 0, 14, PRICE_CLOSE, 0);;
double cci_1 = iCCI(NULL, 0, 14, PRICE_CLOSE, 1);;

if ( ClosePips){
int slip=3;
for (int trade2 = OrdersTotal() - 1; trade2 >= 0; trade2--) {
   OrderSelect( trade2, SELECT_BY_POS, MODE_TRADES);
   if (OrderSymbol() == Symbol()) {
   if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
   if ((OrderType() == OP_BUY)&&( cci_0< cci_1 что сюда вписать???)) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
   if ((OrderType() == OP_SELL)&&( cci_0> cci_1 что сюда вписать???)) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);
   }Sleep(1000);}}}
будет ли это корректным если прописать вот так?
if ((OrderType() == OP_BUY)&&( cci_0< cci_1 && Bid - OrderOpenPrice()<=Point* profit ))

 
Alive писал(а) >>
For some symbols, for example EUR/USD, quotes are 5 decimal places. However, my environment variables have values only 4 decimal places. How can I get the full value of environment variables?

And how did you look at them. Print() always outputs up to 4 characters. Preferably use DoubleToStr();

 
Martingeil >> :

I have faced with the problem with CCI locking, do you know how to implement condition on CCI in the function.

A condition must be set and the order must be closed at the 10pp profit level.

1) if CCI is looking down, at 10pp profit level we close a buy order.

2) Sell - similarly.



You have to do this

if (OrderType()==OP_BUY && cci_0< cci_1 && Bid-OrderOpenPrice()>=Point* profit)
 
MrSoros >> :

That's the way it has to be.


Thank you! That's it if I do it right, I'm not messing with the signs, am I?

extern bool ClosePips   = true;//использовать закрытие ордера при профите 10пп по условиям ССИ

int start(){
double cci_0 = iCCI(NULL, 0, 14, PRICE_CLOSE, 0);;
double cci_1 = iCCI(NULL, 0, 14, PRICE_CLOSE, 1);;

if ( ClosePips){
int slip=3;
int profit=10;
for (int trade2 = OrdersTotal() - 1; trade2 >= 0; trade2--) {
   OrderSelect( trade2, SELECT_BY_POS, MODE_TRADES);
   if (OrderSymbol() == Symbol()) {
   if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
   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);
   }Sleep(1000);}}}
 
Martingeil >> :

Thank you! If I do this right, is there anything wrong with the signs?


The signs are correct.

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

I've been through this before...

But it's a question of strategy.

As many traders as there are strategies...

 

Can you tell me how to write the operator correctly, something with "or" doesn't work, it buys where it shouldn't.

Thank you!
if (
   {( ma1> ma2 && ma1> ma3  && Open[1]> ma1)} || 
   {( ma2> ma1 && ma2> ma3  && Open[1]> ma1)} ||
   {( ma3> ma1 && ma3> ma2  && Open[1]> ma1)}
   )
    OpenBuy();

ну и т. д.


 
Remove the curly braces, they are unnecessary. I wonder how it compiled in the first place.
 
granit77 >> :
Remove the curly brackets, they are unnecessary. I wonder how it compiled at all?

Compiled it both ways and it still doesn't work.

(Strangely enough, it compiled =))

 
costy_ >> :

I've compiled both ways and it still doesn't work.

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

- >> that's good logic.

question - are the conditions themselves correct?

 
Show what ma1...ma3 is and describe the logic in words. In the morning, someone will be eager to correct it :))