Help with int init() with Expert Advisor

 

When I first attach my expert to the chart, it runs int init().

What ever functions I have placed here are to be executed once without a new incoming tick, but I don't think that is happening.

This is where I am getting confused.

My objects are not drawing until int start() is called with 1st tick.


int init()

{ CreateAll();

 return(0); }

void CreateAll()

{ BuyMarketObjects();
  SellMarketObjects();
  BuyModifyObjects();
  SellModifyObjects();
 
  }
  
  return;

void <---- all of them called here

int start()
{
 
Place WindowRedraw() just after creating new objects or changing their properties. Otherwise you need chart to be redrawn automaticaly and that won't happen until a new tick appears.
 
int init()

{ CreateAll();

 return(0); }

void CreateAll()

{ BuyMarketObjects();
  SellMarketObjects();
  BuyModifyObjects();
  SellModifyObjects();
 
  }
  
//  return;   ---- Why do you have a return outside your function?
 
void <---- all of them called here

int start()
{
 

@ hasayama thank you. I'll add WindowRedraw();

@ enotrek, just a mistake. Thank you for pointing that out.

 
Also during Init, market bars may not yet be available (except in the tester,) typically when the terminal is starting up the EA gets attached but history from the server hasn't yet refreshed. You need to do it in start. Also Init is called when the EA is attached, chart is changed (pair, time frame, or refresh) Make sure you can handle those cases.