Any questions from a PROFI to a SUPER PROFI - 1. - page 22

 
int start()
  {
//----
   int massa=100,shag=10,kol=4;
   perebor(massa,shag,kol);
//----
   return(0);
  }
//+------------------------------------------------------------------+
void perebor(int massa, int shag, int kol)
   {
   int massiv[];
   ArrayResize(massiv,kol);
   int x=kol;
   int handle = FileOpen("test.csv",FILE_WRITE,' ');
   
   recurs(massa,shag,massiv,x,kol,handle);
   FileClose(handle);
   }
void recurs  (int massa, int shag, int & massiv[], int x, int kol, int handle)
   { 
   int i,y;
   for(i=0;i<=massa;i+=shag)
      {
      if(x-1>0)
         {
         massiv[kol-x]=i;         
         recurs(massa-i,shag,massiv,x-1,kol,handle);                  
         }
      else
         {
         massiv[kol-x]=massa-i;
         for(y=0;y<kol;y++)
            {            
            FileWrite(handle,y," - ",massiv[y]);
            }
         return;   
         }   
      }
   } 
 
Thank you very much for the code. I'm having a hard time understanding how it works though:)
 
You correctly wrote that the problem should be solved recursively. There is a given number of elements. As long as the element is not the last, the function enters itself with a reduced mass value by the value of all the increments in the previous iterations. On the last element, simply calculate the last residual and print.
 

what am I missing in the function that the button is not visible ?

This is a function in a DLL:

#define IDB_BUTTON   6500

//------------------------------------------------------------------
int __stdcall CreateBtn(int hWnd)
{
  HWND wnd=(HWND)hWnd; // хендл окна чарта
  HWND pwnd=GetParent(wnd); // получили родителя для создания кнопки
  ShowWindow(wnd, SW_HIDE); // скрыли чарт
  // создали кнопку
  HWND btn=CreateWindow("Button", "DLL BUTTON", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 
                15, 15, 100, 100, pwnd, (HMENU)IDB_BUTTON, (HINSTANCE)GetModuleHandle(NULL), NULL);
  ShowWindow(btn, SW_SHOW); // показали кнопку
  UpdateWindow(btn);

  // нарисовали на ней текст (для проверки что окно кнопки существует)
  HDC hdc = GetDC(btn);
  TextOut(hdc, 0, 0, (LPSTR)"String", 6);
  ReleaseDC(btn, hdc);
  RECT Rect; 
  GetWindowRect(btn,  &Rect); // получили размер
  return(Rect.right-Rect.left);  // вернули для проверки размера
}

when the function is called from the script - everything goes perfectly.

The chart at the top shows the text "String", the function itself returns the correct button width number 100.

But the button is not visible.

-------------

ZS
Found the problem - forgot to do UpdateWindow .
Thank you all :)


 
how to disable news on the chart in MT5????
 
parkhomenko:
how to disable news in MT5 that is displayed on the chart????

know besthere
 

Do you have any ideas on how to call "Notepad" from MT4?

I'm tired of storing data in .txt and opening it by hand (with mouse). I would like to open Notepad file ..МТ4\experts\files\data.txt after completing computations

thanks

 
#import "shell32.dll"
   int ShellExecuteA(int hwnd, string oper, string prog, string param, string dir, int show);
#import

ShellExecuteA(0, "Open", "notepad.exe", "data.txt", TerminalPath()+"\\experts\\files", 3);
 

how do you change plus to minus by condition?

it looks like from the realm of fiction, if plus or minus had a value of int integer type, you could set int pl = +;)))

maybe there's an option.......

if(......) + ; else -;
 
Martingeil:

how do I change the plus from the minus in the condition?



select S=1 or S=-1. then multiply the required value by S

for example like this:

double S(bool b) 
{
  if (b) return(1); else return(-1); 
}

a=123;
Print(a*S(a<0))
Print(a*S(a==123))

Reason: