Download MetaTrader 5
To add comments, please log in or register
Publish your article to let the traders see it in MetaTrader 5!
Max Enrik
645
Max Enrik 2016.11.26 18:17 

Hi, 

I try to use 'else {}' code when market closed just it could play.

But two sounds mixed, where is a problem, please?

// SELL
if( sparam == "SELL GROUP" )
{
    ObjectSetInteger ( 0, "SELL GROUP", OBJPROP_STATE, false );
    _ticket = Order  (    "SELL GROUP"                       );

    PlaySound ( "ok.wav" );
}
else
{
    PlaySound( "timeout.wav" );
}

Best.

(English is not my native language) 

Marco vd Heijden
Moderator
4162
Marco vd Heijden 2016.11.26 18:53  
timeout.wav will sound for any/every sparam other then "SELL GROUP".
Max Enrik
645
Max Enrik 2016.11.26 19:02  

Thanks for the comment.

I tried like below, now market is closed 'timeout.wav' playing. But I am not sure 'ok.wav' will play for new order or not?

Can you let me know, please?

int _ticket = 0;
if ( expression )
{
...  
}   //---if Close

if ( _ticket > 0 )
{
    PlaySound( "ok" );
}   //---if Close
//---
if ( _ticket < 0 )
{
    PlaySound( "timeout.wav" );
}   //---if Close

Thanks. 

Marco vd Heijden
Moderator
4162
Marco vd Heijden 2016.11.27 00:10  

Replace with print function and run it in the tester.

From what i can see it is correct.

You could use -1 in stead of <0 but the result would be similar.

Max Enrik
645
Max Enrik 2016.11.27 00:51  

OK! Thanks. I will try it on Monday.

//--- second time edited

Works good.

Max Enrik
645
Max Enrik 2016.11.27 04:03  
Actually I want to add 'OrderLots' function to my main TradePanel EA's but before I need to test it.
So I try to when I click '-' button then lot will decrease, but it does not work for me.

You can see my 'test' EA's codes. I need a help, please.

int             i                                                ,
                int_example         = 1                          ;
double          _lotStep            = 0.01                       ,
                _lot                = 0.09                       ;
string          _prefix             = "| TP -"                   ,
                _edtLot             = _prefix + " Lot"           ,
                _btnLotMinus        = _prefix + " Button Minus"  ;

//---init
_PanelDraw();

//---OnChartEvent
if ( sparam == _btnLotMinus )
{
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_STATE, false );
    _lot = _lot - _lotStep;
    if ( _lot <= 0 )
         _lot = _lotStep;

    Print( "| Just You Clicked Button Lot Minues" );
    return;
}   //---if Close

//---
void _PanelDraw()
{
//---Button
    ObjectCreate    ( 0, _btnLotMinus, OBJ_BUTTON         , 0, 0, 0   );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_XDISTANCE  , 16        );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_YDISTANCE  , 16        );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_XSIZE      , 80        );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_YSIZE      , 32        );
    ObjectSetString ( 0, _btnLotMinus, OBJPROP_TEXT       , "-"       );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_FONTSIZE   , 20        );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_STATE      , false     );
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_SELECTABLE , false     );
    Print( "I am Minus" );

//---Lot
    ObjectCreate    ( 0, _edtLot,      OBJ_EDIT           , 0, 0, 0   );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_COLOR      , Red       );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_XDISTANCE  , 16        );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_YDISTANCE  , 56        );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_XSIZE      , 80        );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_YSIZE      , 32        );
    ObjectSetString ( 0, _edtLot,      OBJPROP_TEXT       , "Lot: " + DoubleToStr( _lot, 2 ) );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_FONTSIZE   , 12        );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_STATE      , true      );
    ObjectSetInteger( 0, _edtLot,      OBJPROP_READONLY   , true      );
    Print( "I am Minus" );
    //---
    return;
}

Thanks! 

Keith Watford
Moderator
8780
Keith Watford 2016.11.27 05:27  

//---OnChartEvent
if ( sparam == _btnLotMinus )
{
    ObjectSetInteger( 0, _btnLotMinus, OBJPROP_STATE, false );
    _lot = _lot - _lotStep;
    if ( _lot <= 0 )
         _lot = _lotStep;

    Print( "| Just You Clicked Button Lot Minues" );
    return;
}   //---if Close

This is not the OnChartEvent function

This is

void OnChartEvent(const int id,         // Event ID
                  const long& lparam,   // Parameter of type long event
                  const double& dparam, // Parameter of type double event
                  const string& sparam  // Parameter of type string events
  );

   if(id==CHARTEVENT_OBJECT_CLICK)

     {

     //

     }


Max Enrik
645
Max Enrik 2016.11.27 13:15  

Keith Watford:

This is not the OnChartEvent function

This is

I still need help about #5

--- 

But why I did not wrote it? Because it takes more spaces...

Anyway thanks.

Marco vd Heijden
Moderator
4162
Marco vd Heijden 2016.11.27 14:02  

it seems to be ok but make sure lotstep itself does not go below 0.01

Max Enrik
645
Max Enrik 2016.11.27 14:06  
But lot doesn't decrease I did not see it.
Keith Watford
Moderator
8780
Keith Watford 2016.11.27 22:32  
Max Enrik:
But lot doesn't decrease I did not see it.

Where do you expect to see it?

Print( "| Just You Clicked Button Lot Minues" );
Does this print?
/ /12345678...23
To add comments, please log in or register