Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1378

 

Help me control the scale of the chart from the keyboard.

The chart window is manually created, I don't know what object name to use inObjectSetInteger, I decided to do it through ChartObject.mqh to be sure.

In onchartivent I write

CChartObject object;  

      if(lparam=='9')
        Print(object.SetInteger(OBJPROP_CHART_SCALE,0,4));


In the log I get false. How can I beat this?

 
MakarFX:
extern variables - what are they?

is not a constant incumbent. There is only one in 4.

 
psyman:

Help me control the scale of the chart from the keyboard.

The chart window is manually created, I don't know what object name to use inObjectSetInteger, I decided to do it through ChartObject.mqh to be sure.

In onchartivent I write


In the log I get false. How can I beat this?

#define  KEY_UP             38 
#define  KEY_DOWN           40 

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
 {
//---
   if(id==CHARTEVENT_KEYDOWN) {
    static int p=(int)ChartGetInteger(0,CHART_SCALE);
     if(lparam==KEY_UP) {
      if(p>4) p=-1;
       if(p<5) {
         ChartSetInteger(0,CHART_SCALE,++p);
       }
     }
     if(lparam==KEY_DOWN) {
      if(p<1) p=6;
       if(p>0) {
         ChartSetInteger(0,CHART_SCALE,--p);
       }
     }
   }
 }
 
MakarFX:

1 The condition is too vague to help...

2 Use different "magiks"

Let me try to explain.

A buy signal has been triggered.

I open a BUY, SELLSTOP is set at the level of its STOPLOSS.

If BUY is closed by TAKEPROFIT, we wait for the next entry signal.

If the price hits the STOPLOSS order and SELLSTOP triggers, then BUYSTOP is being placed at the STOPLOSS level. And so on, until the last order closes in the open position. In other words, we roll back and forth.

 
Forallf:

Let me try to explain.

A buy signal has been received.

I open BUY, SELLSTOP is set at the level of STOPLOSS.

If BUY is closed by TAKEPROFIT, we wait for the next entry signal.

If the price hits the STOPLOSS order and SELLSTOP triggers, then BUYSTOP is being placed at the STOPLOSS level. And so on, until the last order closes in the open position. In other words, we roll back and forth.

What does series two mean?
 
MakarFX:
What does the second series mean?

We start a series of reversal orders (like in the previous post), which will end up with a winning order.

But before the first series is completed, there may be a new signal to BUY or SELL. We should enter the market based on a new signal according to the known principle (the second order series is launched).

There may be a third and a fourth one. The second one should be dealt with)

 
Forallf:

Let me try to explain.

A buy signal has been received.

I open BUY, SELLSTOP is set at the level of STOPLOSS.

If BUY is closed by TAKEPROFIT, we wait for the next entry signal.

If the price hits the STOPLOSS order and SELLSTOP triggers, then BUYSTOP is being placed at the STOPLOSS level. And so on, until the last order closes in the open position. This means that we go back and forth.

like this, but without orders ( SELLSTOP - BUYSTOP ) as soon as the position closes, it opens in the opposite direction (the first position has to be opened manually)

Snapshot.PNG

Files:
 
SanAlex:

like this - but without orders ( SELLSTOP - BUYSTOP ) as the position is closed it is opened in the opposite direction (the first position has to be opened manually)


Thank you. I have seen such Expert Advisors. But I have a need for one with stop orders. And for mt4.

 
Forallf:

Thank you. I've seen advisors like this. But I need them with stop orders. And for mt4.

Do you want help or an EA?
 
Forallf:

Thank you. I've seen advisors like this. But I need them with stop orders. And for mt4.

I suggested it - it's up to you to decide. - It may be useful for someone.

Reason: