[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 515

 
edyuson:

I'm not blaming you, it's not my puzzle. I just found a similar algorithm, which I need and am trying to finish it, just like I need it. https://www.mql5.com/ru/code/9927 What I removed, what I left.

i want it 0.01,0.01,0.01; 0.02,0.02,0.02; 0.04,0.04,0.04; 0.08,0.08,0.08......

some do it via an array
 
YOUNGA:
some do it through an array


like this:

double mas[3];
int q;
int w;

for (int z=OrdersHistoryTotal()-1; z>0; z--)
{
 OrderSelect(z, SELECT_BY_POS, MODE_HISTORY);
 if (OrderSymbol()==Symbol())
 {
  if (OrderProfit()>0 || q>=3) break;
  if (OrderProfit()<0)
  {
  mas[q]=OrderLots();
  q++;
  }
 }
}
if (mas[0]<0 && mas[1]<0 && mas[2]<0) w=1; //Ваше условие
 

Hi!

People, can you advise me how to check if a currency pair is available when starting an indicator?

I'm sick and tired of fighting with this em-ku-el.

Here is the code:

[CODE]

extern string CurrencyPair = "";
string gsSymbol, gsIndiName;

bool bIndicatorError;

...

int start() {

if (StringLen(CurrencyPair) == 0)
gsSymbol = Symbol();

else

gsSymbol = CurrencyPair;

Comment(MarketInfo(gsSymbol, MODE_TRADEALLOWED)); // ЗАКОВЫКА ЗДЕСЬ, это чудо всегда возвращает 0.0000000 при старте терминала. Если же потом открыть свойства индикатора и даже ничего не поправлять в параметрах, то возвращает 1.000000

if (!MarketInfo(gsSymbol, MODE_TRADEALLOWED)) {
Alert(gsIndiName, ": Trade is not allowed for symbol [", gsSymbol,"]");
bIndicatorError = true;
return(-1);
}

}

[CODE]

Maybe there is an easier and more reliable way.

In general, I don't understand how you can write programs in a language where the basic functions work and then don't work.

 
Can you tell me if it is possible to make a script with customizable parameters? I think I've seen a script somewhere that prompts you to enter the parameters when you run it.
 
sss2019:
Can you tell me if it is possible to make a script with customizable parameters? I think I've seen a script somewhere that prompts you to enter the parameters when you run it.
Make the external parameters extern in the script
 
artmedia70:
make the extern parameters extern in the script


I have made the parameters

extern string StartTime = "2011.01.01";
extern string EndTime = "2011.01.25";

but for some reason the script doesn't display their settings before execution

 
Dobr:


like this:

double mas[3];
int q;
int w;

for (int z=OrdersHistoryTotal()-1; z>0; z--)
{
 OrderSelect(z, SELECT_BY_POS, MODE_HISTORY);
 if (OrderSymbol()==Symbol())
 {
  if (OrderProfit()>0 || q>=3) break;
  if (OrderProfit()<0)
  {
  mas[q]=OrderLots();
  q++;
  }
 }
}
if (mas[0]<0 && mas[1]<0 && mas[2]<0) w=1; //Ваше условие
0.01,0.02,0.04,0.08,0.16... I need it 0.01,0.01,0.01; 0.02,0.02,0.02; 0.04,0.04,0.04; 0.08,0.08,0.08......
 
sss2019:


I made the parameters

but for some reason the script does not display their settings before execution

https://docs.mql4.com/ru/basis/preprosessor/compilation
 
edyuson:
0.01, 0.02, 0.04, 0.08, 0.16... I need it 0.01,0.01,0.01; 0.02,0.02,0.02; 0.04,0.04,0.04; 0.08,0.08,0.08......


I wrote EXAMPLE... ;)

here's a more accurate version:

double mas[3]={0,0,0};
int q=0;
int w=0;
int z=0;
for (z=OrdersHistoryTotal()-1;z>0; z--)
{
 OrderSelect(z, SELECT_BY_POS, MODE_HISTORY);
 if (OrderSymbol()==Symbol())
 {
  if (OrderProfit()>0 || q==3) break;
  if (OrderProfit()<0)
  {
  mas[q]=OrderLots();
  q++;
  }
 }
}
if (mas[0]==lot && mas[1]==lot && mas[2]==lot) w=1;
if (w==1) lot=OrderLots()*2;
 
ForexTader:


In general, I don't understand how you can write programmes in a language where the basic functions work, and then they don't.


You can try to transfer part of the checks from init to start. You can also check the status of the terminal, and so on.
Reason: