EnumToString((ENUM_TIMEFRAMES)Period()) problem

 

this is more of a  gee whiz type question, but not knowing the answer tends to annoy me..... does anyone know why "EnumToString((ENUM_TIMEFRAMES)Period())" will not work in stop or limit orders.... it will work in market orders..... 

yes it's a seemingly minor issue especially when just using Period() corrects it....... but it weighs on my mind some...... thanks......h

//-----

  
//-----  this will not send a comment with the order if EnumToString((ENUM_TIMEFRAMES)Period()) is included..... such as in next line....

    ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(bbands,Digits),0,stoploss,takeprofit,EnumToString((ENUM_TIMEFRAMES)Period())+" bbands trailing buystop",BbandsMagicNumber,0,Red);


//------ this will send a comment as would be expected.... i replaced EnumToString((ENUM_TIMEFRAMES)Period()) with Period()..... such as in next line....

      ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(psar,Digits),0,stoploss,takeprofit,Period()+"  psar trailing buystop ",PsarMagicNumber,0,Red);


//----- all market orders have no trouble with EnumToString((ENUM_TIMEFRAMES)Period())..... the comment goes thru as expected..... such as next line.....

    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,takeprofit,EnumToString((ENUM_TIMEFRAMES)Period())+"  ao buy",0,0,clrGreen);
 

enum is not an 'official' type so you can't use it for type casting!

You'd better use (string)Periode()+ ...

 
Carl Schreiber:

enum is not an 'official' type so you can't use it for type casting!

You'd better use (string)Periode()+ ...

void OnStart(){
   PrintFormat("%s == %i", EnumToString((ENUM_TIMEFRAMES)Period()),_Period);
}
2017.05.08 08:25:49.171    testscr AUDJPY,M1: uninit reason 0
2017.05.08 08:25:49.171    testscr AUDJPY,M1: PERIOD_M1 == 1
2017.05.08 08:25:49.171    testscr AUDJPY,M1: initialized
Works fine for me.


Bruce Sullivan: does anyone know why "EnumToString((ENUM_TIMEFRAMES)Period())" will not work in stop or limit orders.
Not a good idea, brokers can change comments, including complete replacement.
 
Carl Schreiber:

enum is not an 'official' type so you can't use it for type casting!

You'd better use (string)Periode()+ ...


hey carl..... thanks for the reply..... yes actually that is what i use now on the pending orders as a work a round.....  DoubleToStr(Period(),0) ......h
 
whroeder1:
Works fine for me.


Not a good idea, brokers can change comments, including complete replacement.


hey whroeder......  thanks..... was hoping you'd reply....  the only place that seems to be an issue is when it's used in a pending orders comment..... the exact same comment will work as expected in any market order.....

when used in a pending order comment, the entire comment is empty.....h

 
No need for the comment, use a range of MNs.
 

There may be a size limit on the string. My guess is 32 characters.

StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()),7)+" bbands trail buystop"   
 
Ernst Van Der Merwe:

There may be a size limit on the string. My guess is 32 characters.


hey ernst..... thanks..... you are absolutely right..... once i took out that extra space it reduced the string to 31 characters and the comment went thru as expected..... thanks again......h
Reason: