Questions from Beginners MQL4 MT4 MetaTrader 4 - page 93

 
seny:

Please help, here's an example

It works like this...

but not like this...

how do I write in the buffer via the k variable?

double k=0;
 
Alekseu Fedotov:
double k=0;

Doesn't help! not in the code body, not in the initialisation, not in the start...

 
seny:

it works like this... and not like this...

To understand, you have to simplify. Compare two expressions: 100/10/10 = 1 and k=10/10 100/k = 100 but if k=10*10, then it is correct

 
Greetings. Could you please tell me how to make the timeline extend to the future when the timeline offset is enabled?
 
Andrey Sokolov:
Greetings. Could you please tell me how to extend the timeline for the future when the chart offset is enabled?

You can't. You can only draw the vertical lines yourself - they show the time at the bottom.

 

Hello. Can you tell me how to write a condition whereby: if an open order closed at TakeProfit - delete all the remaining market orders; if not (closed at Stop Loss) - place the same exact order (with the same Stop Loss and Take Profit) as a pending order.

 
6737998:

Hello. Can you tell me how to write a condition whereby: if an open order closed at a takeprofit - delete all the remaining market orders; if not (closed at stoploss) - put the same exact order (with the same stoploss and takeprofit) as a pending order.


I told you in another thread - work with history and wrote the operators you need to do this.

 

Or you could write an article in the "Articles" section about some forex phenomenon,
and at the bottom of the article place an advertisement for a paid indicator from the market, an indicator that can be used to investigate this phenomenon. ?

 

Hi all, encountered a problem...

The task is to interactively change an EA on a chart. I am not considering an option with several charts and several EAs.

I know about using ChartApplyTemplate and it works, but sometimes it returns false response on the grounds that it cannot place a command in the queue.

What is this queue, where can I read about it or how can I clear this queue, since my task must be given priority over all others?

Thanks in advance.

PS: This does not happen with manual change of template. Maybe then through winAPI try... need to dig, haven't worked with this

ChartApplyTemplate - Chart Operations - MQL4 Reference
ChartApplyTemplate - Chart Operations - MQL4 Reference
  • docs.mql4.com
ChartApplyTemplate - Chart Operations - MQL4 Reference
 
Vasili Taucci:

Hi all, encountered a problem...

The task is to interactively change an EA on a chart. I am not considering an option with several charts and several EAs.

I know about using ChartApplyTemplate and it works, but sometimes it returns false response on the grounds that it cannot place a command in the queue.

What is this queue, where can I read about it or how can I clear this queue, since my task must be given priority over all others?

Thanks in advance.

PS: This does not happen with manual change of template. Maybe then through winAPI try... Need to dig, haven't worked with that

Have a look at this. It's for MT5, but the principle is completely similar for MT4. When using ChartApplyTemplate you need mandatory synchronization, which you can do in the ticket as follows

  static bool TemplateApply( const long Chart_ID, const string &Str, const bool Sync = true )
  {
    string TmpStr = Str;

    const bool SyncFlag = (Sync && Chart_ID && (Chart_ID != ::ChartID()) && !::IsStopped());

    if (SyncFlag)
    {
      const color ColorStopLevel = (color)::ChartGetInteger(Chart_ID, CHART_COLOR_STOP_LEVEL);

      if ((bool)(ColorStopLevel >> 24))
        ::ChartSetInteger(Chart_ID, CHART_COLOR_STOP_LEVEL, ColorStopLevel & 0xFFFFFF);

      const int NewColorStopLevel = (int)EXPERT::StringBetween(TmpStr, EXPERT_STOPLEVEL, STRING_END) | (0x01 << 24);

      TmpStr = Str;
      EXPERT::StringReplace(TmpStr, EXPERT_STOPLEVEL, STRING_END, EXPERT_STOPLEVEL + (string)NewColorStopLevel + STRING_END);
    }

    short Data[];
    const bool Res = ::StringToShortArray(TmpStr, Data, 0, ::StringLen(TmpStr)) &&
                     ::FileSave(FILENAME, Data) && ::ChartApplyTemplate((ulong)Chart_ID, FILENAME);

    if (Res && SyncFlag)
    {
      long Value;

      while ((!::IsStopped() && ::ChartGetInteger(Chart_ID, CHART_COLOR_STOP_LEVEL, 0, Value) && (!(bool)((int)Value >> 24))))
        ::Sleep(0);

      ::ChartSetInteger(Chart_ID, CHART_COLOR_STOP_LEVEL, (int)Value & 0xFFFFFF);
    }

    return(Res);
  }
Expert
Expert
  • votes: 12
  • 2017.08.28
  • fxsaber
  • www.mql5.com
Библиотека чтения/записи параметров произвольных советников.
Reason: