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

 
Can you tell me which code to write, so that when the deal is closed, the next deal can be opened only on the next bar?
 
Can you please tell me how to make candlesticks on the price chart to be coloured green when Awesome Oscillator and Acceleration/Deceleration Oscillator are green, to be coloured red when Awesome Oscillator and Acceleration/Deceleration Oscillator are red, and when indicators are of different colours, candlesticks should be grey?
 
gmMarat писал(а) >>
Can you tell me which code should be written to close a deal, so that the next deal could be opened only on the next bar?

So the question is: How do you close the deal? Is it a stop (which is more complicated), or do we close it ourselves? If we close it ourselves, it's much easier.

 
Nosferatu писал(а) >>
Can you please tell me how to make candlesticks on the price chart to be colored green when Awesome Oscillator and Acceleration/Deceleration Oscillator are green, to be colored red when Awesome Oscillator and Acceleration/Deceleration Oscillator are red, and when indicators are different colours, to make candlesticks gray?

I've never painted a candlestick, but I've definitely seen this turkey in the base. Really, about four months ago. Look it up.

 
infinum13 >> :

So the question is: How do you close the deal? Is it a stop (which is more complicated), or do we close it ourselves? If we close it ourselves, it's much easier.

The trades are closed at Take Profit or Stop Loss!

 

Question.

I have an indicator that writes a quote for the tool like this - 2321.50000000


How can I get rid of extra zeros?

 

Very good about writing experts here. http://www.vedikhin.ru/2006/06/expert-advisors-overview.html

And may the forex gods forgive me, it's in Wordov format .

Files:
 

Help me too.

Limitations of the compiler. I would like to know about restrictions on arrays (how many arrays or total number of elements or something else like allocated memory), and on number of global variables in the sense of superglobals.

 

Hi all.

I decided to write an expert. Took a Stoch for it. I think it should have only one order, but it will sell above 80 and close below 50. I have also added StopLoss in order to reduce losses. I have tested it. The expert seems to be working, but sometimes StopLosses are taken one after another. So I decided to change trading conditions after the first Loss to make them significantly differ from the initial ones. For this purpose, I introduced the isCloseLastPosByStop function I took from Kima and liked it. If Loss is worked, it sends signals and writes in the journal; after the signal if(SSL==true) I set new sale conditions. I have written it, compiled it, launched it - it works, but it also takes several LossO in some places in a row to make it stop. Since I'm not very experienced in MQL4 I do not know what is wrong. Please help me in any way you can..... we are not from around here...... And maybe someone will tell me how to implement this idea in another way. Thanks in advance, this is a good place, I have never gone without qualified advice....


#property copyright "Alex"

#property link "http://www.сайта.net"
//---- input parameters
extern int int MagicNamber=88881;
extern int K_per=30;
extern int D_per=8;
extern int Slow=10;
extern double Lots=1.0;
extern double StopLoss=300;
extern double SSL=0;

//+------------------------------------------------------------------+

int start()
{
int
cnt=0,
ticket,
total;
double
StochK_0, // K line value
StochD_1, // value of line D
SL=StopLoss;
isCloseLastPosByStop();
if (Bars<100)
{
Print("bars less than 100");
return(0);
}
StochK_0=iStochastic(NULL, 0, K_per,D_per,Slow,MODE_SMA,0,MODE_MAIN, 0); // K
StochD_1=iStochastic(NULL, 0, K_per,D_per,Slow,MODE_SMA,0,MODE_MAIN, 2); //D
total=OrdersTotal();
if(total<1)
if ((StochK_0>StochD_1) && StochD_1 > 80) // sales condition
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*Point,0, "My EXP", MagicNamber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice())
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
for(cnt=0;cnt<total;cnt++)
{
RefreshRates();
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // this is an open position? OP_BUY or OP_SELL
OrderSymbol()==Symbol()) // tool match?
{
if(OrderType()==OP_SELL) // position is open
SSL=isCloseLastPosByStop();
if(SSL==true)

{
Print("StopLoss");
}
total=OrdersTotal();
if(total<1)
if ((StochK_0<StochD_1) && StochK_0 < 50) // sales condition if StopLoss is triggered
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*Point,0, "My EXP", MagicNamber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice())
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
for(cnt=0;cnt<total;cnt++)
{
RefreshRates();
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // this is an open position? OP_BUY or OP_SELL
OrderSymbol()==Symbol()) // tool match?
{
if(OrderType()==OP_SELL) // position is open
{
if(StochK_0>StochD_1 && StochD_1 < 50) // close condition
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0); // exit
}}}}}}}
//___user fu-ya
bool isCloseLastPosByStop(string sy="", int op=-1, int mn=-1) {
datetime t;
double ocp, osl;
int dg, i, j=-1, k=OrdersHistoryTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()==sy || sy==") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (t<OrderCloseTime()) {
t=OrderCloseTime();
j=i;
}}}}}}}
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
dg=MarketInfo(sy, MODE_DIGITS);
if (dg==0) if (StringFind(OrderSymbol(), "JPY")<0) dg=4; else dg=2;
ocp=NormalizeDouble(OrderClosePrice(), dg);
osl=NormalizeDouble(OrderStopLoss(), dg);
if (ocp==osl) return(True);
}
return(False);
}
 
luka писал(а) >>

Question.

I have an indicator that writes a quote for the tool like this - 2321.50000000

How to get rid of extra zeros?

The DoubleToStr() operator will help you.

Reason: