Questions from Beginners MQL4 MT4 MetaTrader 4 - page 99

 

I want to make a chick to count profit after every 5 orders. it seems to count, but there is an error "4051 Invalid value of function parameter" why?


input int input_step=5;
int step=input_step;

void start()
{
int h, history=OrdersHistoryTotal();
double orderProfit=0;
 if(history==step)
  {
   for(h=history; h<=history; h--)
    {
    if(OrderSelect(h,SELECT_BY_POS,MODE_HISTORY)==true)
      {
      orderProfit=orderProfit+OrderProfit();
      Print("profit=",orderProfit);
      } 
    }
    step=step+input_step;
  }
  return;
}



 

Hello Dear Guru ...

Scrolling through data in terminal window > History ...

... ...and somehow moved the location of the Terminal window above the chart windows ...

... Can someone suggest how to move the Terminal window back down below the chart windows?


I would be very THANKFUL.

 
Yaroslav Nykula:

Hello Dear Guru ...

Scrolling through data in terminal window > History ...

... ...and somehow moved the location of the Terminal window above the chart windows ...

... Can someone suggest how to move the Terminal window back down below the chart windows?


I would be very THANKFUL.


Grab the bar below the cross with your mouse and drag it wherever you like.

 

Hi, could you please tell me how to make an EA stop trading after three losses (with the same magic number)? After one loss this way

int flag==0;

for(int pos_buy=OrdersHistoryTotal()-1; pos_buy>=0; pos_buy--)

{

if(OrderSelect(pos_buy,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY)

{

if(OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))

flag=1; }}


What about three losses...?

 
Alekseu Fedotov:

Grab the bar below the cross with your mouse and drag it wherever you like.


Thank you ... I double-clicked it and dragged it down... I didn't think of it myself.

 
defailer7:

Hi, could you please tell me how to make an EA stop trading after three losses (with the same magic number)? After one loss this way

int flag==0;

for(int pos_buy=OrdersHistoryTotal()-1; pos_buy>=0; pos_buy--)

{

if(OrderSelect(pos_buy,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY)

{

if(OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))

flag=1; }}


What about three losses?

I'm a beginner myself. maybe it can be done this way

for(int pos_buy=OrdersHistoryTotal()-1; pos_buy>=0; pos_buy--) 
           {
            if(OrderSelect(pos_buy,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY) 
             {
             if (OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))
             flag=1; }
            if(OrderSelect(pos_buy-1,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY) 
             {
             if (OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))
             flag2=1; }
            if(OrderSelect(pos_buy-2,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY) 
             {
             if (OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))
             flag3=1; }
           }
  if(flag==1 && flag2==1 && flag3==1)bool flag_trex=true;
 
Baruandreas:

I'm a beginner myself. It could probably be done like this


Thank you very much, it all worked out.

 

Hi.
Can you tell me how to limit EA trading by time.
I've tried a lot of methods from the forum, but nothing worked, I don't understand anything about writing.
It would be nice if you could just point the finger at what to put in.

 
defailer7:

Hello, could you please tell me how to make an EA stop trading after three losses (with the same magic number)? After one loss this way

int flag==0;

for(int pos_buy=OrdersHistoryTotal()-1; pos_buy>=0; pos_buy--)

{

if(OrderSelect(pos_buy,SELECT_BY_POS,MODE_HISTORY) && OrderType()==OP_BUY)

{

if(OrderSymbol() == Symbol() && (OrderMagicNumber() == Magic_buy )&&(OrderProfit()>0))

flag=1; }}


How about three losses...?


I'm just learning too!!! Flag++, if (flag==3)exit;

And the loss is less than zero.
 
kuzhakov:

Hi.
Can you please advise how to timeframe the EA.
I tried a lot of methods from forum, but nothing works.
It would be nice if I could just point the finger where to insert the message.


I can't send you the finished code, I'm browsing from my phone.

There is a function that returns bar open time

Try adding a number to the function which will return the open time of the bar with the period of a day

Returns the value of the bar open time (specified by the shift parameter) for the corresponding chart.

datetimeiTime(
stringsymbol,// symbol
inttimeframe,// period
intshift//shift
);


Period day

Shift 0

iTime(euro, day, today is zero)+1= Time 00-00-01

There are 60 seconds in one minute

iTime(euro, day, today is zero)+60= time 00-01-00-00 and so on.

For example, we want our EA to start working on 01-00-00

if((iTime(Symbol(),PERIOD D1,0)+3600)<TimeCurent() work

That's all I can help you with on the phone.

You can also return the current hour minutes and compare them, good luck!

Reason: