Here we need to place pending orders and calculate their prices relative to the previous bar close price. BUYSTOP is placed, while SELLSTOP returns error 130. Is there an error in this code? Or in another function.
void SetOrders() {
double ldStop=0, ldTake=0;
int spr=MarketInfo(Symbol(), MODE_SPREAD);
double PredBar=iClose(NULL,PERIOD_M5,1);
double pAsk=PredBar+(DistanceSet+spr)*Point;
double pBid=PredBar-(DistanceSet+spr)*Point;
if (!ExistOrder(1)) {
if (StopLoss!=0) ldStop=pAsk-StopLoss*Point;
if (TakeProfit!=0) ldTake=pAsk+TakeProfit*Point;
SetOrder(OP_BUYSTOP, pAsk, ldStop, ldTake, 1);
}
if (!ExistOrder(2)) {
if (StopLoss!=0) ldStop=PredBar+(StopLoss*Point);
if (TakeProfit!=0) ldTake=pBid-TakeProfit*Point;
SetOrder(OP_SELLSTOP, pBid, ldStop, ldTake, 2);
}
}
Why don't you address the author? He's still alive and young, not old! The coordinates are in the code above each function! Everyone knows him and respects him!
And learn how to insert code like this, with SRC!
void SetOrders() {
double ldStop=0, ldTake=0;
int spr=MarketInfo(Symbol(), MODE_SPREAD);
double PredBar=iClose(NULL,PERIOD_M5,1);
double pAsk=PredBar+(DistanceSet+spr)*Point;
double pBid=PredBar-(DistanceSet+spr)*Point;
if (!ExistOrder(1)) {
if (StopLoss!=0) ldStop=pAsk-StopLoss*Point;
if (TakeProfit!=0) ldTake=pAsk+TakeProfit*Point;
SetOrder(OP_BUYSTOP, pAsk, ldStop, ldTake, 1);
}
if (!ExistOrder(2)) {
if (StopLoss!=0) ldStop=PredBar+(StopLoss*Point);
if (TakeProfit!=0) ldTake=pBid-TakeProfit*Point;
SetOrder(OP_SELLSTOP, pBid, ldStop, ldTake, 2);
}
}
You messed around with PredBar without understanding it, and that's the result! Learn the math first!
Good evening, could you please tell me how to solve the problem with the indicator not working on the new build. When compiling it gives error 'TotalOrders' - illegal switch expression type ( the error is highlighted in the code ). Regards, alexander.
for (i=0; i<k; i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if ((OrderSymbol()==Symb) && (OrderType()==op))
{
ko++;
TotalOrders[ChartListPosition+1][ko][1]=NormalizeDouble(OrderOpenPrice(),dig);
TotalOrders[ChartListPosition+1][ko][2]=NormalizeDouble(OrderStopLoss(),dig);
TotalOrders[ChartListPosition+1][ko][3]=NormalizeDouble(OrderTakeProfit(),dig);
TotalOrders[ChartListPosition+1][ko][4]=OrderTicket();
TotalOrders[ChartListPosition+1][ko][5]=OrderLots();
TotalOrders[ChartListPosition+1][ko][6]=OrderType();
TotalOrders[ChartListPosition+1][ko][7]=OrderMagicNumber();
TotalOrders[ChartListPosition+1][0][0]=ko;
switch(TotalOrders[ChartListPosition+1][ko][6])
{
case OP_BUY:
Type="Buy";
break;
case OP_BUYSTOP:
Type="Buy Stop";
for(int j=1;j<=OrdersCount;j++)
{
switch(TotalOrders[ChartsListPosition+1][j][6])
{
case OP_SELL:
if (TotalOrders[ChartsListPosition+1][j][2]!=0 &&
ask>=(TotalOrders[ChartsListPosition+1][j][2]-NormalizeDouble(StopLevel*point,dig)))
{
test=StopLossColor;
}
else
{
if (TotalOrders[ChartsListPosition+1][j][3]!=0 &&
ask<=(TotalOrders[ChartsListPosition+1][j][3]+NormalizeDouble(StopLevel*point,dig)))
{
test=TakeProfitColor;
}
}
break;
karwin: Good evening, could you please tell me how to solve the problem with the indicator not working on the new build. When compiling it gives error 'TotalOrders' - illegal switch expression type (the error is highlighted in the code). Regards, alexander.
The variable should be there, not something else:
int Переменная=TotalOrders[ChartListPosition+1][ko][6];
switch(Переменная)
{
case OP_BUY:
Type="Buy";
break;
case OP_BUYSTOP:
Type="Buy Stop";
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
Is it so for testing or for optimization? If just testing - one core works, but if you enable "Optimize" option in the strategy tester, all cores of the processor will work.
evillive: you should ask about it on the fifth forum
"I'm not a member of the site, that's why I asked the question here.
barabashkakvn: Is that during testing or optimizing? If you just test - one core works, but when you turn on the option "Optimize" in the strategy tester, will run all the cores of the processor.
I have understood everything, thank you all. During the test one core is working and everything is working as it should be,
I can't understand why they didn't just use the full power of the processor in the test.
"I'm not a member of the site, that's why I asked the question here.
I have understood everything, thank you all. During the test one core is working and everything is working as it should be,
I can't understand why they do not use all the power of the processor in testing.
And why should we load all the cores during testing (without optimization turned on)? After all, if testing with visualization, there is no hurry, and if testing without visualization - so modern computers perform this task like sunflower seeds on a single core.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Here we need to place pending orders and calculate their prices relative to the previous bar close price. BUYSTOP is placed, while SELLSTOP returns error 130. Is there an error in this code? Or in another function.
Why don't you address the author? He's still alive and young, not old! The coordinates are in the code above each function! Everyone knows him and respects him!
And learn how to insert code like this, with SRC!
You messed around with PredBar without understanding it, and that's the result! Learn the math first!
Good evening, could you please tell me how to solve the problem with the indicator not working on the new build. When compiling it gives error 'TotalOrders' - illegal switch expression type (the error is highlighted in the code). Regards, alexander.
The variable should be there, not something else:
Hello comrades.
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
Hello comrades.
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
Hello comrades.
Can you advise me, I'm not very familiar with MT5, I've hardly ever used it, while testing only one CPU core is engaged, I have 8 of them, why is that? How do I fix it?
You messed around with PredBar without understanding, that's the result! Learn the math first!
you should ask about it on the fifth forum
"I'm not a member of the site, that's why I asked the question here.
Is that during testing or optimizing? If you just test - one core works, but when you turn on the option "Optimize" in the strategy tester, will run all the cores of the processor.
I have understood everything, thank you all. During the test one core is working and everything is working as it should be,
I can't understand why they didn't just use the full power of the processor in the test.
"I'm not a member of the site, that's why I asked the question here.
I have understood everything, thank you all. During the test one core is working and everything is working as it should be,
I can't understand why they do not use all the power of the processor in testing.
Thanks, learned it, fixed it.