Goodbye robot - hello marasmus - page 4

 
Mislaid:

Controlling the array boundaries by specifying a string in the code is very useful. It used to be: divide by zero, and look where you want. And it's even worse if the error didn't show up.

Could you provide an example of how to do it? I couldn't find anything about this feature in the documentation.
 
Andrei01:
Could you please give an example how to do this? Didn't find anything about this feature in documentation.

Exactly! You don't need to do anything now. Open the "experts" tab and read the logs. If an error appears, you will see a message about it. Like:

array out of range....... indicating the line number in the code.

 
Mislaid:

Open the 'experts' tab and read the logs.

Does it work for indicators and scripts?
 
Pavlick:

Try changing the case of the first letter of the script/indicator name. Been struggling once too https://www.mql5.com/ru/forum/152533/page2#982156

P.S: well, change string to char[]

Answer, Pavlik!

Good for you Pavlik!

Your code worked right away!

Now you can run the

script!

It remains to be fitted into the indicator!

Your code has been inserted into the indicator!

there is only one small obstacle

indicator doesn't want to recognize the name

of the script. I wrote the name in the place

where the script should be called from.

All that's left is for the script to be

recognized!

can you help me?

sincerely regards

punsa

 
pansa:

Answer, Pavlik!

You're great, Pavlik!

your code worked right away!

now you can run the

the script!

It remains to be fitted into the indicator!

Your code has been inserted into the indicator!

there is only one small obstacle

indicator doesn't want to recognize the name

of the script. I wrote the name in the place

where the script should be called from.

All that's left is for the script to be

recognized!

can you help me?

sincerely regards

Panza




I'll help if you need it
 
There's still one very good catch with these warnings (at least there was). The priority of logical expressions has changed. When the priority is not explicitly defined by brackets, the compiler only gives a warning, although the logical expression now has a completely different effect than before. It must be an error. Somebody may have decided to bail on the warnings, and among them is a warning about a logical expression.
 
Vinin:

I'll help you if you need any help.

Hi, Vinin!

thank you so much

for wanting to help!

I'm sending you for an overview of how the

composter script call

pansa

____________________________________

Hi Pavlik!

I'd like to show you an example

how the script call was organized

composter, now it's not working.

for review

pansa

//+------------------------------------------------------------------+

//|sample_execute_script.mq4 |

//+------------------------------------------------------------------+

#import "user32.dll"

int RegisterWindowMessageA(string MessageName);

int PostMessageA(int hwnd, int msg, int wparam, string Name);

void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);

#import

int start()

{

int winHandle = WindowHandle( Symbol(), Period() );

//

//

//

if( signal < 0 && trigl==true && buy == true ) {StartScript( winHandle, "SchliesenProfitOrders" ); }

//

//

//

void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)

{

int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message");

PostMessageA(hWnd, MessageNumber, 16, ScriptName);

if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }

}

void ClearConfigDialog()

{

Sleep(100);

keybd_event(13, 0, 0, 0);

}

//

//

//

return(0);

 
pansa:

Hi, Vinin!

thank you so much

for wanting to help!

I'm sending you for an overview of how the

composter script call

pansa

____________________________________

Hi Pavlik!

I'd like to show you an example

how the script call was organized

with the composter, now it's not working.

for review

pansa


Is it really hard to click on the SRC and paste the code?!

//+------------------------------------------------------------------+
//|                                        sample_execute_script.mq4 |
//+------------------------------------------------------------------+
#import "user32.dll"
  int RegisterWindowMessageA(string MessageName);
  int PostMessageA(int hwnd, int msg, int wparam, string Name);
  void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);
#import

int start()
{
  int winHandle = WindowHandle( Symbol(), Period() );
//
//
//
  if(signal < 0 && trigl==true && buy == true) 
  {
    StartScript(winHandle, "SchliesenProfitOrders" ); 
  }
//
//
//
}
void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)
{
  int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message");
  PostMessageA(hWnd, MessageNumber, 16, ScriptName);
  if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }
} 
void ClearConfigDialog()
{
  Sleep(100);
  keybd_event(13, 0, 0, 0);
}
//
//
//
return(0);
 
pansa:

This should work fine:

void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)
{
    char buf[];
    StringToCharArray("MetaTrader4_Internal_Message", buf);
    int MT4InternalMsg = RegisterWindowMessageA(buf);
    StringToCharArray(ScriptName, buf);
    SendMessageA(hWnd, MT4InternalMsg, 16, buf);
    if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }
}
void ClearConfigDialog()
{
    Sleep(100);
    keybd_event(13, 0, 0, 0);

}

And don't forget about the case of the first letter of the script, for example, if the script "test" doesn't start, you should try "Test".

Respectfully, Pavlik ))

 
Pavlick:

This should work fine:

And don't forget the case of the first letter of the script, for example, if the script"test" doesn't run, you should try "Test".

Regards, Pavlik )))


Hi Pavlik!

Got your refinement and

tried to put everything in the indicator

but the indicator doesn't want to.

see what you can do

to make it work!

Panza

//+------------------------------------------------------------------+

//|AltrTREND_Signal.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//|https://www.mql5.com ||

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//|AltrTrend_Signal_v2_2_alert.mq4|

//|Ramdass - Conversion only|

//+------------------------------------------------------------------+

#property copyright "Author - OlegVS, GOODMAN"

#property strict

#import "user32.dll"

int RegisterWindowMessageA(uchar &lParam[]);

int SendMessageA(int hWnd, int Msg, int wParam, char &lParam[]);

void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);

#import

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 DeepSkyBlue

#property indicator_color2 OrangeRed

#property indicator_width1 1

#property indicator_width2 1

//---- input parameters

extern bool Alert_message=true;

extern int Time_alert_minutes=60; // ????? ????? ?????????? ???? ??? ? 60 ?????.

extern int K = 30;

extern double Kstop = 0.5;

extern inttern Kperiod = 150;

extern int PeriodADX = 7; //14;

extern int CountBars = 100;

//---- buffers

double val1[];

double val2[];

double AlertTime;

//+------------------------------------------------------------------+

//| Custom indicator initialisation function|

//+------------------------------------------------------------------+

int init()

{

string short_name;

//---- indicator line

IndicatorBuffers(1);

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,241);

IndicatorBuffers(2);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,242);

SetIndexBuffer(0,val1);

SetIndexBuffer(1,val2);

if(CountBars>=Bars)

CountBars=Bars;

SetIndexDrawBegin(0, Bars - CountBars + PeriodADX );

SetIndexDrawBegin(1, Bars - CountBars + PeriodADX );

//----

return(0);

}

//+------------------------------------------------------------------+

//| AltrTrend_Signal_v2_2|

//+------------------------------------------------------------------+

int start()

{

int i, shift, counted_bars = IndicatorCounted();

//----

if(counted_bars<0) return(-1);

//----

int i1, i2, t_per;

double Range, AvgRange, smin, smax, SsMax, SsMin, SSP, price;

bool uptrend, old;

//----

if(Bars <=PeriodADX+ 1)

return(0);

//----

for(shift = CountBars - PeriodADX ; shift >= 0; shift--)

{

SSP = MathCeil(Kperiod / iADX(NULL, 0, PeriodADX , PRICE_CLOSE, MODE_MAIN, 1));

Range = 0;

AvgRange = 0;

for(i1 = shift; i1 <= shift + SSP; i1++)

{

AvgRange = AvgRange + MathAbs(High[i1] - Low[i1]);

}

Range = AvgRange / (SSP + 1);

//----

SsMax = High[shift];

SsMin = Low[shift];

for(i2 = shift; i2 <= shift + SSP - 1; i2++)

{

price = High[i2];

if(SsMax < price)

SsMax= price;

price = Low[i2];

if(SsMin >= price)

SsMin = price;

}

//----

smin = SsMin + (SsMax - SsMin)*K / 100;

smax = SsMax - (SsMax - SsMin)*K / 100;

val1[shift] = 0.0;

val2[shift] = 0.0;

if(Close[shift] < smin)

{

uptrend = false;

}

if(Close[shift] > smax)

{

uptrend = true;

}

if(uptrend != old && uptrend == true)

{

val1[shift] = Low[shift] - Range*Kstop;

}

if(uptrend != old && uptrend == false)

{

val2[shift] = High[shift] + Range*Kstop;

}

old = uptrend;

}

void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)

{

{

char buf[];

StringToCharArray("MetaTrader4_Internal_Message", buf;)

int MT4InternalMsg = RegisterWindowMessageA(buf);

StringToCharArray("fPlayer", buf);

SendMessageA(hWnd, MT4InternalMsg, 16, buf);

if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }

}

void ClearConfigDialog()

{

Sleep(100);

keybd_event(13, 0, 0, 0);

}

//---- Alert

if (Period()<Time_alert_minutes) t_per=Period(); else t_per=Time_alert_minutes; // ???? ??<Time_alert, ????? ????? ?????????? ???? ??? ? ??.

if (Alert_message==true && CurTime()>AlertTime && val1[0]!=0.0)

{

Alert(Symbol(), "+++ BUY !!! +++" , "//AltrTrend_Signal_v2_2_alert ");

AlertTime=CurTime() + (t_per - MathMod(TimeMinute(CurTime()), t_per))*60;

//PlaySound("payment.wav");

fPlayer ;//script

}

if (Alert_message==true && CurTime()>AlertTime && val2[0]!=0.0)

{

Alert(Symbol(), "+++ SELL !!!+++" , "//AltrTrend_Signal_v2_2_alert");

AlertTime=CurTime() + (t_per - MathMod(TimeMinute(CurTime()), t_per))*60;

// PlaySound("payment.wav");

fPlayer ;

}

return(0);

}

//+------------------------------------------------------------------+

Reason: