[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 3

 
artmedia70:
Show all code


The thing is, if you remove the MA-comparison, it works!

If you plug it back in, it does NOT work at all!

int Stoch_1,Stoch_2,Ma_1,Ma_2;


int start()
  {
Ma_1=iMA(NULL,PERIOD_M5,5,0,MODE_LWMA,PRICE_CLOSE,1) ;
Ma_2=iMA(NULL,PERIOD_M5,15,0,MODE_LWMA,PRICE_CLOSE,1) ; 

Stoch_1=iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,0,MODE_MAIN,1); 
Stoch_2=iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,0,MODE_SIGNAL,1);
Print (Ma_1,"___",Ma_2);  // печатает 134 (GBPJPY)

if ( Hour()>10 && Hour()<20) 
 {
  if ( Ma_1 > Ma_2)       // если убрать строку- работает. Оставить - не работает       
      {
                      

//               if (Stoch_1>Stoch_2)


 { SetVLine(Blue, "", 0, 0, 1);} 
 
}}
     
     
  if ( Hour()>10 && Hour()<20) 
   {
  if ( Ma_1<Ma_2)       // если убрать строку- работает. Оставить - не работает    
     {
                               
 
 // if (Stoch_1<Stoch_2)                      
 

              {SetVLine(Red, "", 0, 0, 1);} 
  
  
}  }

} return(0); //}
//---------------------------
//+----------------------------------------------------------------------------+
void SetVLine(color cl, string nm="", datetime t1=0, int st=0, int wd=1) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (t1<=0) t1=Time[0];
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_VLINE, 0, 0,0);
  ObjectSet(nm, OBJPROP_TIME1, t1);
  ObjectSet(nm, OBJPROP_COLOR, cl);
  ObjectSet(nm, OBJPROP_STYLE, st);
  ObjectSet(nm, OBJPROP_WIDTH, wd);
  }
 
artmedia70:

MA_1 and MA_2 must be of type double.

What's your type?


"But I've always been the queen of hearts" (c) "12 Chairs"

and I've always put them in int

 
rigonich:
Yes, as you were told above, if the variables are of the int type they will give 1 for the euras, because converting1.3075 to the int type gives 1, and you are probably printing your variables and not the average values.


gbkznm.... what a shame!!! exactly! int is a WHOLE number and double is a floating point....

shame!

 
lottamer:

and I've always stuck them in the int

I'm full of knowledge! :)))
 

EVERYTHING SEEMS TO BE WORKING!!!

THANK YOU SO MUCH!!!

Thought it was over.... :))))))

 
TarasBY:
Knowledge - FULL trousers! :)))


I repent......
 
lottamer:


"But I've always been the queen of hearts" (c) "12 Chairs"

and I've always had them in the int


Variables of int type are integers, and when you set them to a number with a fractional part, the number is rounded to the nearest whole number first, and then the value of that number is set to an int variable.
 
If you put a double variable into an int, I know what will happen. But what if we do the reverse operation? int todouble won't be worse, right?
 

Teach me, for Christ's sake, how to work with comments:

1. if a comment is already made, or is being made, how can I not paste it, but go on to make another comment, if, for example, the question has already been answered?

2. if a code is inserted, how do I go on to insert plain text after inserting it? Enter continues entering text as code.

3. when copying, some things it inserts by default, e.g. when copying from help, the copied is inserted as a link.How do I paste the copied as plain text?

 
lottamer:
If you put a double variable into an int, I know what will happen. But what if you do the reverse operation? int todouble won't make it worse, will it?
A variable can only be placed in a certain place in computer memory, which has its own address and size.What you are talking about is called assigning to a variable of type double the value of a number of type int.This is possible, the value of this variablewill be represented as a number of type double with a fractional part equal to 0
Reason: