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
Below code works perfectly after you helped me, thanks man.
And I renamed as you said, it works good, but just I am wondering, am I doing something wrong?
( just I am Worry about )
Worrying whether your code will work is very normal (indeed it is healthy). Frequently we will see code that compiles but doesn't do what we want (because of human error and/or lack of knowledge).
The best way is to get into the habit of printing variables and checking return codes. Once you have tested, you can remove the print statements.
Using your code snippet above, you could add a simple Print("SL value: "+sl) and then check your Expert log to see if the values are what you expect.
It's simple if it works as designed your not doing anything wrong otherwise it simply doesn't work.
#Checkmark - Closed
Yeah! I accept this bitmap label already took a long time from me. Finally, I got what I want...
Of course, huge man, thanks for your help.
I solve my issue like below code.
{
// Sell set Stop Loss with bitmap label
// when bitmap label shows - ON
if ( ObjectGetInteger( 0, "bitmap label on off", OBJPROP_STATE ) == true )
{
sl = Bid + points_to_change( stoploss * 10 );
Print( " | TRUE : Active | ", "Bid: ", Bid, " | ", "Stop Loss: ", sl );
}
// when bitmap label shows - OFF
if ( ObjectGetInteger( 0, "bitmap label on off", OBJPROP_STATE ) == false )
{
sl = 0;
Print( " | FALSE : Inactive | ", "Bid: ", Bid, " | ", "Stop Loss: ", sl );
}
// call your stop loss 'sl'
ticket = OrderSend( ..., sl, ... );
// sounds
if ( ticket > 0 )
{ PlaySound( "ok.wav" ); } else
{ PlaySound( "timeout.wav" ); }
return;
}
The best way is to get into the habit of printing variables and checking return codes. Once you have tested, you can remove the print statements.
Using your code snippet above, you could add a simple Print("SL value: "+sl) and then check your Expert log to see if the values are what you expect.
I already use it, but sometimes I doubt my code because if you check my #Checkmark issue, I hope you will understand me more clearly.
Anyway thanks for your time.
Why are you multiplying by 10? If stoploss is in pips, convert it via pips_to_change so it works on 4 digit brokers.
Oh! Yeah man, good question, I already changed. Thanks for your attention.
#Stop Loss / Take Profit - Closed
Thanks for your more clearly comments Marco.
Special thanks to @Marco vd HeijdenAll the best to you.
#Ctrl + Mouse Button - Open
I spent few hours, how can I find good documentation about that, and I can't got any good information and documentation for it.
I just need when I click 'Left Mouse + Ctrl' for Lot size increase by 0.1. ( is normally increase by 0.01 ).
I want to find documentation and articles with example about that.
Thanks in advance.
#Ctrl + Mouse Button - Open
I spent few hours, how can I find good documentation about that, and I can't got any good information and documentation for it.
I just need when I click 'Left Mouse + Ctrl' for Lot size increase by 0.1. ( is normally increase by 0.01 ).
I want to find documentation and articles with example about that.
Thanks in advance.
I don't know of an easy way to trap key combinations. It would be better to have a second button to click if you want to increase by 0.1 rather than 0.01.
Nevertheless, you can try the following:
Check if the last event was a keystroke CTRL.
If it was, check if this event is a mouse click.
But, there are some problems with this approach:
1. If any other chart event happens between the keystroke and the mouse click, it fails.
2. You will get some overrun caused by the delay between the mouse click and releasing CTRL. The workarounds to this will introduce their own problems.
Perhaps some other people will have better ideas.
const long &lparam,
const double &dparam,
const string &sparam)
{
static bool wasCTRL=false;
if(wasCTRL && id==CHARTEVENT_CLICK) Print("CTRL+CLICK detected");
wasCTRL=(id==CHARTEVENT_KEYDOWN && lparam==CTRL);
}
//| keydown.mq4 |
//| Copyright 2016, Marco vd Heijden, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Marco vd Heijden, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
bool ctrl_click;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if(id==CHARTEVENT_CLICK)
{
//Print("CLICK");
ctrl_click=1;
}
if(id==CHARTEVENT_KEYDOWN)
{
//Print(lparam);// print to identify keycode
if(lparam==17) // ctrl key
{
if(ctrl_click==1)// if mouse click
{
//Do Something when CTRL (keycode 17) is pressed
Print("CTRL+CLICK");
ctrl_click=0; // reset
}
}
ctrl_click=0; // reset if not ctrl
}
}
//+------------------------------------------------------------------+
I guess so.
It's slightly different tho.