[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 180

 

Help) What is the bug in the code) in the tester all is fine) and in the demo all is dead) has not been the case for several days) Here is the code)

extern inttern Tenkan=5;
extern int dd=9;
extern int slowing=3;
extern int kk=9;
extern inttern UrovenUp=56;
extern double TakeProfit=100;
extern double Lots=3;
extern double StopLoss=100;

int start()
{double MY,priceBuy,priceBuy2,Ich,D,K,K1;
double Cc1,C2,C3,C4;
int ticket;


MY=(Open[0] + Close[0] )/2;
Ich=((Open[iHighest(NULL, 0, MODE_OPEN, Tenkan)]) +
(Close[iLowest(NULL, 0, MODE_CLOSE, Tenkan)]))/2;

D=(iStochastic(NULL,0,kk,dd,slowing,MODE_SMA,0,MODE_SIGNAL,0));
K=(iStochastic(NULL,0,kk,dd,slowing,MODE_SMA,0,MODE_MAIN,0))
K1=(iStochastic(NULL,0,kk,dd,slowing,MODE_SMA,0,MODE_MAIN,1))
Cc1=Close[2] < Close[1];
C2=Close[0] > Close[1];
C3=K>K1;
C4=D<UrovenUp;


//Buy and sell price condition//
priceBuy=MarketInfo(Symbol(),MODE_ASK);
priceBuy2=MarketInfo(Symbol(),MODE_BID);


//condition to buy//


{if (MY > Ich && Cc1 && C2 && C3 && C4)

//ticket=OrderS³; //ticket=OrderS³; //condition for buying and selling//
{ticket=OrderSend(Symbol(),OP_BUY,Lots,priceBuy,3,priceBuy2-StopLoss*Point,priceBuy2+TakeProfit*Point,
"My baby",123453,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}

}

}



 
Dimka-novitsek:
But IndicatorCounted( ) ...?

I would advise not to bother with this function yet, but borrow ready-made pieces of code from reputable programmers. I, for example, steal code from Winin :))
And later you can figure it out on your own.
 
MikeM:
If the calculation is quite complex, then unnecessary recalculation of thousands of unchanged bars is a big waste of time. You have to have time before the next tick, and it can come in 250 milliseconds (on my server)

Thank you!!!
 
What counts in this way?
res=ZigzagBuffer[i];
I mean, I don't understand the concept of a buffer!
 
Dimka-novitsek:
What counts in this way?
This operator does not count anything. It simply copies an array element into a simple variable. We have to assume that this value is involved in some further calculations. If the res variable is not used anywhere else in the program, there is no sense in this operator either.
 
Dimka-novitsek:
I mean, I don't understand the concept of a buffer!
You can think of a buffer as virtual video memory. That is, what you write to the buffer will appear on the screen.
 
Dimka-novitsek:
What counts in this way? I mean, I don't understand the concept of a buffer!
Good article on indicators (textbook section). It may come in handy.

https://book.mql4.com/ru/samples/icustom
 
kakbutak:


This restriction may cause that the first order will not be opened.

I have an option... For example, if today after a sell trade the balance went up by TP, then prohibit a sell trade for today, if a buy trade, then prohibit a buy trade. But I do not know how to code it.

if (((Ask>=OrderTakeProfit()) && (OrderType() == OP_BUY)) {x=1;}

if((Bid<=OrderTakeProfit()) && (OrderType() == OP_SELL)) {y=1;}

if(Hour()==00:00) {x=0;y=0;}

BUY x=0; SELL y=0;

 
MikeM:
You can think of the buffer as virtual video memory. That is, what you write to the buffer will be displayed on the screen.

granit77


Thank you!!!

 

Afternoon! "double x;" code that would remember the variable "x" after the terminal is reloaded. Thank you.