All chart events will reset your X,Y coordinates since you commented out the event filter
//if(id==CHARTEVENT_MOUSE_MOVE){int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
ChartXYToTimePrice(0,x,y,window,dt,price);
Comment(x,I,y,I,dt,I,price);
//Print(x,I,y,I,dt,I,price);//double value = NormalizeDouble(price,digits);
So imagine a keystroke event setting your x and y to the values appropriate for said event. Now your previous x,y value are overwritten with the wrong type inputs.
All chart events will reset your X,Y coordinates since you commented out the event filter
So imagine a keystroke event setting your x and y to the values appropriate for said event. Now your previous x,y value are overwritten with the wrong type inputs.
Yeah, now I see my wrong thinking, coz I closed bracket after ChartXYToTimePrice as bellow and values was 0, now moved initialization to the global and I have what I should have.
if(id==CHARTEVENT_MOUSE_MOVE){int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
ChartXYToTimePrice(0,x,y,window,dt,price);
}
Can you confirm for me that trading with repeating of keys like B-buy or S-sell working corect? Coz for me orders are placed only once in case that function by keys is call everytime, eg. modify order working always just order send of any of type working once time.
Can you confirm for me that trading with repeating of keys like B-buy or S-sell working corect? Coz for me orders are placed only once in case that function by keys is call everytime, eg. modify order working always just order send of any of type working once time.
boolChartTimePriceToXY(
long chart_id, // Chart IDint sub_window, // The number of the subwindow <<<<--------------------- datetime time, // Time on the chartdouble price, // Price on the chartint& x, // The X coordinate for the time on the chartint& y // The Y coordinates for the price on the chart
);
boolChartXYToTimePrice(
long chart_id, // Chart IDint x, // The X coordinate on the chartint y, // The Y coordinate on the chartint& sub_window, // The number of the subwindow <<<<<---------------------datetime& time, // Time on the chartdouble& price // Price on the chart
)
And '0' - variable expected in ChartXYToTimePrice, so can't be
The snipet was all of program that have problem : )
In attachemnt file of this EA.
Ok, so here's my feedback.
You need to learn how to use the debugger to step into and trace bugs in your code. Not only do you have an error in the scope of the block that manages the XY to TimePrice, but there are errors in multiple functions; too many for me to continue debugging your code -- but here's just one example.
result=OrderSend(Symbol(),OP_BUY,_Lot,price,Slippage,SL,TP,signal,Magic,0,Blue); check_result(result);
//result variable is global. This should be local! //OrderSend doesn't return a boolean, it returns the ticket number//Don't ever put two statements on one line. There is an infinite amount of vertical white-space. Use it.//Just this one line refactored to remove bugs looks like this.int ticket = OrderSend(Symbol(),OP_BUY,_Lot,price,Slippage,SL,TP,signal,Magic,0,Blue);
bool result = ticket >= 0;
check_result(result);
//additionally you are passing in 0 as a lot arg then referencing a different global lots variable within the function -- then ultimately sending the order with 0 lots
//the whole structure is spaghetti-like and needs refactoring
You are abusing global variables which will always cause you issues. Global variables should be limited as much as possible and should really only be const values. Also you should name them using the convention-prefix of "g_" + "variable_name" (g_variable) so you can figure out which ones are global vs local.
All chart events will reset your X,Y coordinates since you commented out the event filter
So imagine a keystroke event setting your x and y to the values appropriate for said event. Now your previous x,y value are overwritten with the wrong type inputs.
All chart events will reset your X,Y coordinates since you commented out the event filter
So imagine a keystroke event setting your x and y to the values appropriate for said event. Now your previous x,y value are overwritten with the wrong type inputs.
Yeah, now I see my wrong thinking, coz I closed bracket after ChartXYToTimePrice as bellow and values was 0, now moved initialization to the global and I have what I should have.
Will test rest of code around live trading.
Thx for uncache me ;]@nicholi shen
Can you confirm for me that trading with repeating of keys like B-buy or S-sell working corect? Coz for me orders are placed only once in case that function by keys is call everytime, eg. modify order working always just order send of any of type working once time.
@nicholi shen
Can you confirm for me that trading with repeating of keys like B-buy or S-sell working corect? Coz for me orders are placed only once in case that function by keys is call everytime, eg. modify order working always just order send of any of type working once time.
Sure post your code.
BTW.. strange, that the convention is diffrent
https://docs.mql4.com/chart_operations/charttimepricetoxy
https://docs.mql4.com/chart_operations/chartxytotimeprice
And '0' - variable expected in ChartXYToTimePrice, so can't be
bool XYtoCTP = ChartXYToTimePrice(0,x,y,0,dt_x,price_y);
must be
int window = 0;
bool XYtoCTP = ChartXYToTimePrice(0,x,y,window,dt_x,price_y);
..heh.. gifts from MQ
Sure post your code.
It was posted in previous post.
In case that ChartXYToTimePrice was related in problem with variables trading calls by keys was ok, just the problem with repeating.
It was posted in previous post.
In case that ChartXYToTimePrice was related in problem with variables trading calls by keys was ok, just the problem with repeating.
You posted a tiny snippet. Need the whole program.
You posted a tiny snippet. Need the whole program.
The snipet was all of program that have problem : )
In attachemnt file of this EA.
The snipet was all of program that have problem : )
In attachemnt file of this EA.
Ok, so here's my feedback.
You need to learn how to use the debugger to step into and trace bugs in your code. Not only do you have an error in the scope of the block that manages the XY to TimePrice, but there are errors in multiple functions; too many for me to continue debugging your code -- but here's just one example.
You are abusing global variables which will always cause you issues. Global variables should be limited as much as possible and should really only be const values. Also you should name them using the convention-prefix of "g_" + "variable_name" (g_variable) so you can figure out which ones are global vs local.