Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1434

 
#include <JAson.mqh>
CJAVal jv;

jv["type"] = "BTCUSD";
jv["title"] = "test";

int result;
char res_data[],post[];
ArrayResize(post,StringToCharArray(jv.Serialize(),post,0,WHOLE_ARRAY)-1);
string headers="Content-Type: application/json\r\nAccept: text/plain";
result=WebRequest("POST",url,headers,3000,post,res_data,res_headers);

Trying to send json via WebRequest, the server returns:"\u0022BTCUSD\u0022 is not a valid bundle type for denormalisation.".

I.e. it doesn't like the encoding of inverted commas \u0022 .
I tried specifying all encoding variants in headers and
StringToCharArray, nothing helps.

From python everything flies out without problems:
response = requests.post(url, data=json.dumps(data), headers=headers)
i.e. everything is ok with the server.

How to solve the problem?

 

Let me rephrase the question a bit differently. Is it possible to give the optimiser a command in the OnInit block to skip the testing/optimization variant under certain conditions.

input group "Входные настройки Стохастик"
input bool Stoch = false; // Стохастик включен/выключен
input int in_StochK = 14; // период основной линии K
input int in_StochD = 3; // период первичного сглаживания D
input int in_StochSlow = 3; // период окончательного сглаживания

int OnInit() {
if ((Stoch = false) && ((StochK != 0) || (StochK != 0) || (StochSlow != 0)))
   {
   // Некая команда, которая говорит, что такой вариант даже не стоит пробовать оптимизировать  
   }
}

I tried to do this, but it leads to incorrect optimisation variants.

if ((Stoch = false) && ((StochK != 0) || (StochK != 0) || (StochSlow != 0))) 
   {
   
Print("Такой вариант тестирования не имеет смысла");
   return(INIT_FAILED);
   }

The goal is for me to be able to enable the enumeration of variants of 4 stochastic parameters (Stoch, in_StochK, int in_StochD, int in_StochSlow) when optimising.

  • When stochastic is enabled (Stoch = true), the optimiser is enumerating the variables in_StochK, in_StochD, in_StochSlow. Everything works correctly in this part.
  • When stochastic is turned off (Stoch = false), the optimiser still searches variables in_StochK, in_StochD, in_StochSlow. And I need to make some kind of a stopper in the code so that it does not search them if Stoch = false.
 

Hello @taramortom.

It would probably help if you just replaced

return(INIT_FAILED)

to

return(INIT_PARAMETERS_INCORRECT)
 
Yuriy Bykov #:

Hello, @taramortom.

It would probably help if you just replace

to

I tried that. It doesn't work. The optimiser still works incorrectly with this command.
 

Perhaps the reason the optimiser is not working correctly is because of this inaccuracy in the code:

if ((Stoch = false) && ((StochK != 0) || (StochK != 0) || (StochSlow != 0)))
 
Yuriy Bykov #:

Perhaps the reason the optimiser is not working correctly is because of this inaccuracy in the code:


That is not the reason. I made the code for an example of the working logic. The full version of the code is too large - there are many different oscillators. When optimising, I want the optimiser to try different combinations (one oscillator on, two oscillators on, three oscillators on, etc.).

- When using this stopper, the optimiser quickly completes work with a small number of passes, although there should be a huge number of them.

- Without using this restriction, the optimiser works better, but produces a lot of empty variants (for the example above - it still searches its parameters when Stochastic is turned off). God be with empty variants, but this is both extra time for optimisation and empty passes instead of useful ones.

 
Are you using genetic or full optimisation?
I also used this approach to exclude obviously unnecessary combinations of parameters and did not notice incorrect optimiser performance. On the contrary, the optimiser worked exactly as expected.
You can try to add saving the missed parameter combinations to the database or a common file to check how many and which ones are really missed and to understand the reasons.
 

Hello! I am writing an indicator based on MA - ExtJawsHandle=iMA(NULL,0,Period,0,Method,AppliedPrice);

how can I programmatically get to the levels of MA, as shown in the figure below.

A construct of the type

IndicatorSetInteger(INDICATOR_LEVELS,1);

IndicatorSetDouble(INDICATOR_LEVELVALUE,0,10);

does not work.


 
Tango_X IndicatorSetInteger(INDICATOR_LEVELS,1);

IndicatorSetDouble(INDICATOR_LEVELVALUE,0,10);

doesn't work.


no options?)

 
Tango_X #:

no other options?)

What prevents you from looking at the code of the Alligator.mq5 indicator?

//--- line shifts when drawing
   PlotIndexSetInteger(0,PLOT_SHIFT,InpJawsShift);
   PlotIndexSetInteger(1,PLOT_SHIFT,InpTeethShift);
   PlotIndexSetInteger(2,PLOT_SHIFT,InpLipsShift);