[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 304

 
pigvin:

The problem is that the EA constantly reopens orders, i.e. there is a signal to buy - it opens an order, then closes it at profit, and the conditions are still preserved it opens it again.

I thought it could be solved with the traditional buy and sell counter - if the buy order opened the counter +1 and a new buy cannot be opened until the counter is above 0 and the counter is reset only after sell.

I.e. there is a signal on one bar but it has already been used?

You could do it like this

datetime save_time; 
int tf=0;
старт
...
if(total<1)//проверка количества ордеров 
   {
         if(save_time!=iTime(0,tf, iBarShift(0,tf,Time[0])))
            save_time =iTime(0,tf, iBarShift(0,tf,Time[0]));
         else return;


  ...
 if(ticket>0)
                      {
                         if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("открыта позиция BUY : ",OrderOpenPrice());
      
                         else Print("Ошибка при открытии BUY позиции : ",GetLastError()); 
                        }else{ save_time =0;}// так как ошибка запретим ретурн (см. выше)
 
Operr:

Try it like this.

if (OrderOpenTime()+2*1440*60  > Time[0])   //т.е. последнее время текушего графика а не локальное

It should work both ways.

It makes more sense to me.

if (Time[0]-OrderOpenTime() >= 2*1440*60 )   
 

Hello All!

Sorry for the off-topic, the topic is in demand, that's why I'm writing here, can you give me a hint? Stuck.

How, using only elementary operations (+-*/%), to perform exponentiation (including real) of a real number? For example, the wind calculator, when applied to the power of 1.2, gives the result 1.2445647472073939777218169154111826. Interested in the algorithm, the language does not matter, any. I will translate it myself.

ZS. How many programming tests I haven't done, I see such a problem for the first time, although it may be trivial for someone?

 

Good afternoon all!

I searched a lot of forums and google articles, but did not find an answer

I have decided to write an EA to trade on two opposite orders on М1

The idea is simple: put two opposite orders with small TP, then, when the TP of one of them for the second activated timer is the number of bars (say 5), it will be temporary SL. The calculation is that if the currency will move in the same direction, losses when the second order triggers temporary SL will be minimal, if the chart turns around, we are in the black on two positions.

I don't know how to write a code fragment with "when a TP of one of them triggers, the timer for the second one switches on as a number of bars".

i currently only have a timer for two orders at once, but i can't get much out of it

PS I have not solved this problem for a month, please help me with advice or code:)

here is the code of the advisor

extern int SL=100;

extern int TP=100;

extern double StartLot=0.1;

extern double StopLot=1.0;

extern int bar_time=20;


double Lot()

{

double lt;

if(OrdersHistoryTotal()==0) return (StartLot);

if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))

{

if(OrderProfit()<0)

{

lt=OrderLots()*2;

if(lt>StopLot) return (StartLot);

else return (lt);

}

else

return (StartLot);

}

else

return (StartLot);

}

int start()

{

double lot;

if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==False)

{

int order;

{

lot=Lot();

order=OrderSend(Symbol(),OP_BUY,lot,Ask,0,Ask-SL*Point,Ask+TP*Point,0,0,0,Green);

order=OrderSend(Symbol(),OP_SELL,lot,Bid,0,Bid+SL*Point,Bid-TP*Point,0,0,0,Green);

}

}

//вот здесь должно быть что-то что является решением проблемы и связующим звеном

{

int bars = iBarShift( Symbol(), PERIOD_M1, OrderOpenTime() ) ;

if ( iTime( Symbol(), PERIOD_M1, bars ) > OrderOpenTime() ) { bars ++; }

if ( bars >= bar_time )

OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),5,White);

}

return(0);

}


Thanks in advance

 
Not on one bar! In principle, we should not open in this trend until there is no signal for a reversal or market turbulence!
costy_:

I.e. there is a signal on one bar, but it has already been used?

You could do this

 
snail09:

Hello All!

Sorry for the off-topic, the topic is in demand, that's why I'm writing here, can you give me a hint? Stuck.

How, using only elementary operations (+-*/%), to perform exponentiation (including real) of a real number? For example, the wind calculator, when applied to the power of 1.2, gives the result 1.2445647472073939777218169154111826. Interested in the algorithm, the language does not matter, any. I will translate it myself.

ZS. How many programming tests I haven't done, this is the first time I've seen such a problem, though it may be trivial for some people?

https://docs.mql4.com/ru/math/MathPow no? Or elementary operations are a condition of the problem. Then option http://bpascal.ru/download/desc/436.php if you do everything by hand, then implement exponent and logarithm with your own functions.

 
индикаторcosty_:

You use while(i>=0), so when a new candle appears i=1 (to make sure the data of the previous candle is calculated on the fixed data once).

Why enter some_time=D'1971.01.11 00:00'; use Bars, IndicatorCounted does not work for me (well, the error is probably because of the first_t_bar).

Your algorithm and you should fix it.

"I'm new to programming."I'm new to programming since 2007).


All the same, I don't understand why my design works well and the standard one doesn't. some_time=D'1971.01.11 00:00'; here it is used once at startup. Then the date is changed to another one. But it has nothing to do with that, because it works in one case and not in another. I will remake the indicator later. This is a modified version of another indicator. Thanks for the reply!

 
Sonne:

Good afternoon all!

I searched a lot of forums and google articles, but did not find an answer

I have decided to write an EA to trade on two opposite orders on М1

The idea is simple: put two opposite orders with small TP, then, when the TP of one of them for the second activated timer is the number of bars (say 5), it will be temporary SL. The calculation is that if the currency will move in the same direction, losses when the second order triggers temporary SL will be minimal, if the chart turns around, we are in the black on two positions.

I don't know how to write a code fragment with "when a TP of one of them triggers, the timer for the second one switches on as a number of bars".

i currently only have a timer for two orders at once, but i can't get much out of it

PS for a month can not solve this problem, please help advice or code:)

here is the code

................................................

I will give my best beforehand thanks in advance.

1. If there is a closed position on a Takei...

1.1 If its type is OP_BUY, ...

1.1.2 If there is an open position OP_SELL, ...

1.1.3 If the time of the current bar minus the time of the bar opening the Sell position is greater than or equal to the number of bars for the delay, ....

1.1.4 We close the Sell position

1.2 If its type is OP_SELL, ...

1.2.2 If there is an open position OP_BUY, ...

1.2.3 If the time of the current bar minus the time of the Buy position opening is greater than or equal to the number of bars to hold, ....

1.2.4 Close Buy position

 
Hello, could you please advise where to get a normal story (without holes) and whether the minute story from MT5 for MT4?
 

Good evening everyone, I apologise for the stupid question before)

I want to know if it is possible for an EA where there is a variable, say "A", to be given a price value at the moment and it trades. If we want to change this value to any historical value, for example, take any monthly value and derive the desired value from the analysis of history. I tried to do it in the strategy tester, but I have many doubts concerning its correctness. Or will I have to redo it and work with arrays! Thank you all.

p.s. I want to know since I didn't find it in the MQL handbook and tutorial.

Reason: