I have some problem with "ObjectCreate"

 

i have write the code like this :

void OnTick()
  {
      // some codes...

        if(!PositionSelect(_Symbol))
        {
            CTrade trade;
            trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,0.1,
                               SymbolInfoDouble(_Symbol,SYMBOL_ASK),
                               0,0,"");
          
            bool res = ObjectCreate(0,"test obj",OBJ_ARROW_THUMB_UP,0,TimeCurrent(),SymbolInfoDouble(_Symbol,SYMBOL_ASK)+1);
           
            if (res) printf("------------ObjectCreate return TURE");
            else printf("----------------ObjectCreate return FALSE");
         }
    

    // some codes.... 

  }

when i run the ea in strategy tester , nothing has create in the chart , and the journal have this "------------ObjectCreate return TURE".

Can someone tell me why?

thanks 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
 
xhxiang:

i have write the code like this :

...

when i run the ea in strategy tester , nothing has create in the chart , and the journal have this "------------ObjectCreate return TURE".

Can someone tell me why?

thanks 

  1. Please use the SRC button when you post code.
  2. Object aren't plotted in normal mode, read here.
 
xhxiang:

i have write the code like this :

void OnTick()
  {
      // some codes...

        if(!PositionSelect(_Symbol))
        {
            CTrade trade;
            trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,0.1,
                               SymbolInfoDouble(_Symbol,SYMBOL_ASK),
                               0,0,"");
           
            bool res = ObjectCreate(0,"test obj",OBJ_ARROW_THUMB_UP,0,TimeCurrent(),SymbolInfoDouble(_Symbol,SYMBOL_ASK)+1);
            
            if (res) printf("------------ObjectCreate return TURE");
            else printf("----------------ObjectCreate return FALSE");
         }
    

    // some codes.... 

  }

when i run the ea in strategy tester , nothing has create in the chart , and the journal have this "------------ObjectCreate return TURE".

Can someone tell me why?

thanks 

Maybe the Objects are created but not at the time or price that you expect,  add a Print()  statement and output the time and price that you are using for the position of the Object and check it is correct.  Print these . . .

TimeCurrent(),SymbolInfoDouble(_Symbol,SYMBOL_ASK)+1

 

Objects are not created when you are running the Optimizer.

 
angevoyageur:
  1. Please use the SRC button when you post code.
  2. Object aren't plotted in normal mode, read here.
thank you for your advice,and i have found the reason.  
 
Also remember that each object must have a unique name.
Br, Candles
 
xhxiang:
thank you for your advice,and i have found the reason.  

Good. because if for example EURUSD is 1.23456, then this code below

SymbolInfoDouble(_Symbol,SYMBOL_ASK)+1

will draw your object on EURUSD at 2.23456.

Just press Ctrl + O to see the object list and you will find your object at about 10,000 pips away :D.

BTW, why you need this arrow ?. Is MT5 deal arrow is not enough ?, you can activate it by open Option (Ctrl + O), click "Trade" tab and select "Show real time history on chart" .

 
phi.nuts:

Good. because if for example EURUSD is 1.23456, then this code below

will draw your object on EURUSD at 2.23456.

Just press Ctrl + O to see the object list and you will find your object at about 10,000 pips away :D.

BTW, why you need this arrow ?. Is MT5 deal arrow is not enough ?, you can activate it by open Option (Ctrl + O), click "Trade" tab and select "Show real time history on chart" .

I was going to suggest the same,  unfortunately that won't work in the Strategy Tester  :-(  how do we get a list of the Objects in the Strategy Tester ?
 
RaptorUK:
I was going to suggest the same,  unfortunately that won't work in the Strategy Tester  :-(  how do we get a list of the Objects in the Strategy Tester ?
Object aren't plotted in Strategy Tester in "normal" mode, and in visual mode you can't almost do anything. Don't know why.
 
angevoyageur:
Object aren't plotted in Strategy Tester in "normal" mode, and in visual mode you can't almost do anything. Don't know why.
In my world Visual Mode  IS normal mode ;-)  I have an indicator that uses Objects without problems in Visual Mode.
 
Candles know the answer for that, it's a ghost in a PC :).
 
phi.nuts:
Candles know the answer for that, it's a ghost in a PC :).
Haha, and it still there :(
Reason: