Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1110

 
Alexey Viktorov:

The documentation tells you how to do this. In fmod you divide by 1 and get the fractional part of the number or 0. You don't care how many decimal places are entered in the field or in the input variable.

It works, it's the easiest solution!

EditCreate(0,"TR",0,0,0,X,Y, fmod(TralingStop,1)==0 ? DoubleToString(TralingStop,0) : DoubleToString(TralingStop,1),true);

Thank you!

 
heik_h = iCustom(_Symbol, PERIOD_CURRENT, "Examples\\Heiken_Ashi");
CopyBuffer(heik_h, 1, 1, 1, heikHigh);
CopyBuffer(heik_h, 2, 1, 1, heikLow);
Comment(heikHigh[0]);   

I get the wrong value, around zero

The indicator is in Examples

What is the problem?

 
Roman Sharanov:

I get the wrong value, around zero

The indicator is in Examples

What's the problem?

Do you create a new indicator handle at every tick?

Handle should be created in OnInit and data should be received in OnTick or OnCalculate.
 
Vladimir Karputov:
Do you create a new indicator handle at every tick?

Handle should be created in OnInit and data should be received in OnTick or OnCalculate.

No, it is in OnInit

 
Roman Sharanov:

No, it is in OnInit


You are inattentive: read the whole sentence, in full: Handle should be created in OnInit, and data should be received in OnTick or OnCalculate.
 
Vladimir Karputov:

You are inattentive: read the whole sentence, in full: Handle should be created in OnInit, and receive data already in OnTick or OnCalculate.

And so it does

 
int OnInit(){
   heik_h = iCustom(_Symbol, PERIOD_CURRENT, "Examples\\Heiken_Ashi");
}
void OnTick(){
   CopyBuffer(heik_h, 1, 1, 1, heikHigh);
   Comment(heikHigh[0]);
}
 

Roman Sharanov:

int OnInit(){
   heik_h = iCustom(_Symbol, PERIOD_CURRENT, "Examples\\Heiken_Ashi");
}
void OnTick(){
   CopyBuffer(heik_h, 1, 1, 1, heikHigh);
   Comment(heikHigh[0]);
}

//+------------------------------------------------------------------+
int OnInit()
  {
   heik_h = iCustom(_Symbol, PERIOD_CURRENT, "Examples\\Heiken_Ashi");
   if(heik_h==INVALID_HANDLE)
      return INIT_FAILED;
   ArraySetAsSeries(heikHigh,true);
  }
void OnTick()
  {
   if(CopyBuffer(heik_h, 1, 1, 1, heikHigh)==1)
      Comment(heikHigh[0]);
  }
//+------------------------------------------------------------------+
 
Artyom Trishkin:

Nothing has changed, it still shows e+321

 
Roman Sharanov:

Nothing has changed, it still shows e+321

UseDoubleToString() to output price values with the desired accuracy

Reason: