timeout.wav will sound for any/every sparam other then "SELL GROUP".
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
if ( expression )
{
...
} //---if Close
if ( _ticket > 0 )
{
PlaySound( "ok" );
} //---if Close
//---
if ( _ticket < 0 )
{
PlaySound( "timeout.wav" );
} //---if Close
Thanks.
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.
OK! Thanks. I will try it on Monday.
//--- second time edited
Works good.
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;
}
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!
//---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)
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)
{
//
}
it seems to be ok but make sure lotstep itself does not go below 0.01
But lot doesn't decrease I did not see it.
Max Enrik:
But lot doesn't decrease I did not see it.
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?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I try to use 'else {}' code when market closed just it could play.
But two sounds mixed, where is a problem, please?
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)