[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 321

 
Boneshapper:

When I write this, I don't write Flag=0 in front of the condition, because then it will be updated every time before a transaction and will always be 0. If we don't specify a value, for example just int Flag, the program will assign it 0, right?

I wrote you code where Flag is outside the start function, not inside it. If you put it inside, it's useless.
 
Roger:

Weird, the code works. Maybe you put it in the wrong place?
I figured it out, the value of Flag was given inside the if, and why it was losing it on exit from it.I put the variable type static int Flag.Everything now works
 
Roger:

I wrote you code in which Flag is outside the start function, not inside. If you put it inside, it is useless.

Sorry, I wrote a reply, but I didn't see your answer.
Yes, yes, you're right. That's exactly my mistake. But the way out was to use Static.

Thank you very much for everything.

 

Good night!

Can you please tell me if there is a function

int start()
{
OrderSend (Symbol(), OP_SELL, Loot,Bid, 50, SL, TP,NULL,1001,0,L);
if (OrderSelect(1001, SELECT_BY_TICKET)== true)
int Ticket = OrderTicket ();
Alert ("Ticket =",Ticket);
OrderClose(Ticket,Loot,Ask,50,R);
}

I don't quite understand how to use magic parameter in ordersend function to search for an order with this number?

And when you use the function

bool OrderSelect( int index, int select)
SELECT_BY_TICKET option, which index should we set?

 

In order to use a magician, it must first be set up, like yours, and then checked for its presence when you go round

int start()
{
OrderSend (Symbol(), OP_SELL, Loot,Bid, 50, SL, TP,NULL,1001,0,L);
//...
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
if(OrderMagic()==1001)
{

Alert ("Ticket =",OrderTicket()); 
OrderClose(OrderTicket(),Loot,Ask,50,R); 
}}}
 

Hi All!!!

I have a question: Is it possible to access trade history from an Expert Advisor (MQL4)?

Namely, that the previous deal was unprofitable and the previous one was profitable, and so on for 10 deals deep into history?

It is necessary for MM, since the Expert Advisor has a series of profitable deals after a large loss trade.

I have an idea: after a losing trade, start increasing your position, for example, in three or five consecutive trades and wait for the next

and wait for the next losing trade.

 

Don't touch everyone, they're still asleep, it's Saturday after all.

Access can be organised, look in codebase for EAs with the control word "martingale" (martingale).

 
Tatar:

Hi All!!!

I have a question: Is it possible to access trade history from an Expert Advisor (MQL4)?

Namely, that the previous deal was unprofitable and the previous one was profitable, and so on for 10 deals deep into history?

It is necessary for MM, since the Expert Advisor has a series of profitable deals after a large loss trade.

I have an idea: after a losing trade, start increasing your position, e.g., in three or five consecutive trades and wait for the next

a losing trade.


Of course it is possible. Look here - you can take the basis for yourself and adjust it to your trading conditions.

Here is an example of organizing positions according to the results of the last closed order (the freshest one in the order history - that is how it is organized in my system)

//---Поиск последнего отработавшего ордера для открытия очередной позиции ---
   
   for (orderIndex = (OrdersHistoryTotal() - 1); orderIndex >= 0; orderIndex--)
   {   
      if (!OrderSelect(orderIndex, SELECT_BY_POS, MODE_HISTORY))
      {
         Print("Ошибка при доступе к исторической базе (",GetLastError(),")");
         continue;
      }
   
      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != MagicNumber))
      {
         continue;
      }
      
        
   //-------------------------Принимаем в расчет только ордер, закрытый недавно-----------------------
if(time<OrderCloseTime())     //(сравниваем его с хранящимся в пероеменной time) 
  {
    time=OrderCloseTime();     //если время закрытия ордера больше - ложим его в переменную
         
         
     
         int lastType = OrderType();
         double lastLots = OrderLots();
         double lastProfit = OrderProfit() + OrderSwap();
         
        // Print ("lastProfit = ", NormalizeDouble(lastProfit, 1));
         
       
         
         // Анализ только что закрывшегося ордера
      
         if (lastProfit >= 0.0)
         {.... Здесь действия, при положительном профите ордера...
 .....
......
......
 
 
artmedia70:

double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

Calculation of moving average.
Parameters:
symbol - Symbol name of symbol, on data of which the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means the period of the current chart.
period - Period of averaging for moving average calculation.
ma_shift - Indicator shift relative to the price chart.
ma_method - Averaging method. Can be any of values of Moving Average methods.
applied_price - Price used. Can be any of price constants.
shift - Index of the value obtained from the indicator buffer (shift relative to the current bar by the specified number of periods back).


As you see ma_shift is an integer (number of bars to shift МАшки line to the right or to the left). And +/-0.21% is double, so it will not work.

Do I understand what you want?

You understand everything correctly. It's just Rumus (Forex Club) has such a possibility and this "envelope" is the base of TS "Intraday Conservative Scalping". I wanted to do the same with MT4. But as you explained it not so :)

 

Rimlyanin:

You understand everything correctly. It's just that Rumus (Forex Club) has such an opportunity and this "envelope" is the basis of the TS "Conservative Intraday Scalping". I wanted to do the same with MT4. But as you explained it not destiny :)

You are misunderstood.

If you need an envelope, the MA is shifted up and down.

The MA is a shift to the left, to the right (as in Alligator).

Reason: