[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 87

 
Mathemat:

Sorry, but it's definitely in the Annals. Ignorance of the English language is no excuse.

I don't know what the EURUSD spread is on the micro, honestly. You are probably banned from this forum. These bastards are always thinking of something to keep you out.

I managed to sign in, thank you.
 

Hello, please help with one, I believe elementary, point.

int start()
{
OrderSend(Symbol(),OP_BUY,1,Ask,2,0,0);
Alert(GetLastError());
return;
}

The script opens a market order and everything is OK. But if I set any value of SL or TP, I get "Wrong Stop" error.

int start()
{
OrderSend(Symbol(),OP_BUY,1,Ask,2,Bid-50*Point,Bid+50*Point);
Alert(GetLastError());
return;
}

This code doesn't work anymore. What's wrong? I cannot figure it out...

int start()
{
OrderSend(Symbol(),OP_BUY,1,Ask,2,1.31845,1.40000);
Alert(GetLastError());
return;
}

And it doesn't work even if I enter numerical values of stop and profit. The minimum distance from order to stop order is ok.

 

Dear Professionals! I have a question. i have an EA, it trades by several criteria, how to make it modify orders separately? for example, i opened two BUY orders by different signals, one breakeven level is 90pp with 40pp increments, another one is 50pp with 50pp increments. i couldn't do it. As i have already tried it i have seen how many signals i have got, and i dont know how to use them. Many thanks in advance!

 
azik1306:

Dear Professionals! I have a question. i have an EA, it trades by several criteria, how to make it modify orders separately? for example, i opened two BUY orders by different signals, one breakeven level is 90pp with 40pp increments, another one is 50pp with 50pp increments. i couldn't do it. As i have already tried it i have seen how many signals i have got, and i dont know how to use them. i have already tried it and i have no idea how to use it.

-It is possible to open trades by different signals with different Magic numbers.

-It is possible to put "marks" (eg, the same level of trawl) in the comment field when opening trades and then analyze it

without seeing the code on your question, I do not quite understand what exactly you want to do separately

 

The code is approximately as follows:

for( int c=1; c<=OrdersTotal(); c++) // Order loop
{
OrderSelect(c-1,SELECT_BY_POS); // If there is another
// Order Analysis:
if(OrderMagicNumber()<1000)

if (R==1 && SL<OrderOpenPrice() && Bid-OrderOpenPrice()>((NoLoss)*Point) )
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*(NoLoss),OrderTakeProfit(),0,Blue);
return;
}
if (R==2 && SL>OrderOpenPrice() && OrderOpenPrice()-Ask>((NoLoss)*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*(NoLoss),OrderTakeProfit(),0,Blue);
return;
}
if (R==1 && SL>=OrderOpenPrice() && Bid - SL > ((NoLoss*Point)+(StepLoss*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss,OrderTakeProfit(),0,Blue);
return;
}
if (R==2 && SL<=OrderOpenPrice() && SL-Ask>((NoLoss*Point)+(StepLoss*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss,OrderTakeProfit(),0,Blue);
return;
}
return;
}
//--------------------------------------------------------------------

for(c=1; c<=OrdersTotal(); c++) // Order loop
{
OrderSelect(c-1,SELECT_BY_POS); // If there is another
// Order Analysis:
if (OrderMagicNumber()>1000)
if (Z==3 && Bid-OrderOpenPrice()>((NoLoss1)*Point) )
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
if (Z==4 && SL1>OrderOpenPrice() && OrderOpenPrice()-Ask>NoLoss1*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
if (Z==3 && SL1>=OrderOpenPrice() && Bid - SL1 > ((NoLoss1*Point)+(StepLoss1*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
if (Z==4 && SL1<=OrderOpenPrice() && SL1-Ask>((NoLoss1*Point)+(StepLoss1*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
return;
}

//--------------------------------------------------------------------
// Order values
RefreshRates(); // Refresh data
Min_Lot=MarketInfo(Symb,MODE_MINLOT); // Min. lots
Free =AccountFreeMargin(); // Free funds
One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);// Value of 1 lot
Step =MarketInfo(Symb,MODE_LOTSTEP); // Step change size

if (Lots > 0) // If lots are set, then
Lts =Lots; // work with them
else // % free funds
Lts=MathFloor(Free*Prots/One_Lot/Step)*Step;// To open

if(Lts < Min_Lot) Lts=Min_Lot; // Not less than minimum
if(Lts*One_Lot > Free) // Lots more expensive than free.
{
Alert(" Not enough money ", Lts," Lots");
return; // Exit start()
}
//--------------------------------------------------------------- 8 --
// Opening orders

{
if (Total<2 && Opn_B==true && B==false)
{
// criterion to open a Buy order. Buy
RefreshRates(); // Update data
SL=Bid - New_Stop(StopLoss)*Point; // Calculation of SL open.
TP=Bid + New_Stop(TakeProfit)*Point; // Calculation of TP open.
Alert("Attempting to open Buy. Waiting for reply...");
Ticket=OrderSend(Symb,OP_BUY,Lts,Ask,2,SL,TP,NULL,y);//Open Buy
if (Ticket > 0) // It worked :)
{
Alert ("Opened Buy order ",Ticket);
B=true;
S=false;
Y=OrderMagicNumber();
R=1;
return; // Exit start()
}
if (Fun_Error(GetLastError())==1) // Error handling
continue; // Retry
// Exit start()
}
if (Total<2 && Opn_S==true && S==false) // Open orders. none +
{
Sleep(10000); // open Sell crit. Sell
RefreshRates(); // Update data
SL=Ask + New_Stop(StopLoss)*Point; // Calculation of SL open.
TP=Ask - New_Stop(TakeProfit)*Point; // Calculation of TP open.
Alert("Attempting to open Sell. Waiting for reply...");
Ticket=OrderSend(Symb,OP_SELL,Lts,Bid,2,SL,TP,NULL,y);//Open Sel
if (Ticket > 0) // It worked :)
{
Alert ("Sell order opened ",Ticket);
S=true;
B=false;
Y=OrderMagicNumber();
R=2;
return; // Exit start()
}
if (Fun_Error(GetLastError())==1) // Error handling
continue; // Retry
// Exit start()
}

if (Total<2 && Opn_B1==true && B1==false)
{
RefreshRates(); // Update data
SL1=Bid - New_Stop1(StopLoss1)*Point; // Calculate SL open
TP1=Bid + New_Stop1(TakeProfit1)*Point; // Calculation of TP open.
Alert("Attempting to open Buy. Waiting for reply...");
Ticket=OrderSend(Symb,OP_BUY,Lts,Ask,2,SL1,TP1,NULL,x);//Open Buy
if (Ticket > 0) // It worked :)
{
Alert ("Opened Buy order ",Ticket);
B1=true;
S1=false;
X=OrderMagicNumber();
Z=3;
return; // Exit start()
}
if (Fun_Error(GetLastError())==1) // Error handling
continue; // Retry
// Exit start()
}
if (Total<2 && Opn_S1==true && S1==false) // Open orders. none +
{
Sleep(10000); // open Sell crit. Sell
RefreshRates(); // Update data
SL1=Ask + New_Stop1(StopLoss1)*Point; // Calculation of SL open.
TP1=Ask - New_Stop1(TakeProfit1)*Point; // Calculation of TP open.
Alert("Attempting to open Sell. Waiting for reply...");
Ticket=OrderSend(Symb,OP_SELL,Lts,Bid,2,SL1,TP1,NULL,x);//Open Sel
if (Ticket > 0) // It worked :)
{
Alert ("Sell order open ",Ticket);
S1=true;
B1=false;
X=OrderMagicNumber();
Z=4;
return; // Exit start()
}
if (Fun_Error(GetLastError())==1) // Error handling
continue; // Retry
// Exit start()
}
break; // Exit while
}

 
Tried both orderselect and majik, EA confuses orders
 
azik1306:

the code is something like this:


Attach such wide codes with a file, or at least with SRC (selectable in the upper editing bar), because it's tiring to read such lines.
 
azik1306:

the code is approximately as follows:

for( int c=1; c<=OrdersTotal(); c++) // Order loop
{
OrderSelect(c-1,SELECT_BY_POS); // If there is a next
// Order analysis:
if(OrderMagicNumber()<1000)
if(R==1 && SL<OrderOpenPrice() && Bid-OrderOpenPrice()>((NoLoss)*Point) )
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*(NoLoss),OrderTakeProfit(),0,Blue);
return;
}
if (R==2 && SL>OrderOpenPrice() && OrderOpenPrice()-Ask>((NoLoss)*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*(NoLoss),OrderTakeProfit(),0,Blue);
return;
}
if (R==1 && SL>=OrderOpenPrice() && Bid - SL > ((NoLoss*Point)+(StepLoss*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss,OrderTakeProfit(),0,Blue);
return;
}
if (R==2 && SL<=OrderOpenPrice() && SL-Ask>((NoLoss*Point)+(StepLoss*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss,OrderTakeProfit(),0,Blue);
return;
}
return;
}
//--------------------------------------------------------------------
// In principle, you don't need to write anything further: it won't be executed anyway

for(c=1; c<=OrdersTotal(); c++) // Order loop

{
OrderSelect(c-1,SELECT_BY_POS); // If there is a next
// Order analysis:
if (OrderMagicNumber()>1000)
if (Z==3 && Bid-OrderOpenPrice()>((NoLoss1)*Point) )
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}

if (Z==4 && SL1>OrderOpenPrice() && OrderOpenPrice()-Ask>NoLoss1*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
if (Z==3 && SL1>=OrderOpenPrice() && Bid - SL1 > ((NoLoss1*Point)+(StepLoss1*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
if (Z==4 && SL1<=OrderOpenPrice() && SL1-Ask>((NoLoss1*Point)+(StepLoss1*Point))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*NoLoss1,OrderTakeProfit(),0,Blue);
return;
}
return ; // But "to be on the safe side", there is also a "test shot" ;)
}

........ Nothing else matters .......

//

//--------------------------------------------------------------------
// Order value

 
Thanks, I'll try it now.
 
Corrected the code, but the EA does not want to approach each order individually