Download MetaTrader 5
To add comments, please log in or register
Have you made a screenshot in MetaTrader? Share it with friends!
shakespeare515
69
shakespeare515 2015.09.20 15:32 

Hi coder/traders,

I was hoping we could start a thread that highlights ways to write code that use less clock time/resources.. If there is a thread already that exists, then my apologies, have not found it yet..

There are a couple questions that maybe someone can help with..

First, is it quicker (and more efficient to assign variables for things such as Bid and Ask, or to just use the predefined variable every time you need them..

double bid,ask;

bid=Bid;
ask=Ask;

 Is there an advantage to using above method? or can we just use Bid or Ask when we need it..

double varA;

if (varA>Bid) Print("higher");

 second case I just use the predefined variable Bid, in the first  I first assign Bid to a user created variable "bid"

-If coding a large EA, will it make a difference in speed/clock time one way or the other?? 

---------------------------------------------------------------

Also...

Same question regarding global variables......

Is it faster to GlobalVariableGet("Global") every time you need it; or to assign the Global to a local variable and access the local when needed...

-------------------------------------------------------------- 

And Finally... Using iCustom() to access an indicator in indicators folder... will it speed up access to indy if it is already loaded on a chart? or is there no difference as long as it is in the custom indicator folder??

and would it be faster to just code the indy into the ea?? so it never has to access indy folder?? 

 

Thanks in advance all, always appreciated.. Alsoo any resources available on this topic would be greatly appreciated.. 

whroeder1
13644
whroeder1 2015.09.20 21:35  
  1. What would be the point of assigning a predefined variable to another variable? A variable access is an access.
  2. GVget is a dictionary lookup. Save it locally for the tick. GVs only change when code changes them. No need for GVs unless you need multiple EAs on multiple charts to interact.
  3. Used to be no difference; the indicator is loaded once, and iCustom reads the buffers. A post several months ago showed the iCustom loads the indicator again.
shakespeare515
69
shakespeare515 2015.09.22 01:08  

Gret thank you!

 

1. Yea that makes sense.

 

2. Yes I use GVs for indys and Eas on seperate charts to communicate

 

3. so is it right that if the indy is loaded on a chart, then a seperate EA calls it using iCustom, it will load a second instance?

 

thanks again 

whroeder1
13644
whroeder1 2015.09.22 13:13  
sammy515: it will load a second instance?
What part of "A post several months ago showed the iCustom loads the indicator again" was unclear?
shakespeare515
69
shakespeare515 2015.09.23 01:23  
WHRoeder:
What part of "A post several months ago showed the iCustom loads the indicator again" was unclear?

great thanks.. making sure I read that right.. 

/
To add comments, please log in or register