//--- 1.1. Define pip -----------------------------------------------------
if(Digits==4 || Digits<=2) pip=Point;
if(Digits==5 || Digits==3) pip=Point*10;
Maybe you can try this.
Code base has a lot of examples for you to examine.

tito78: not work in 4 digit broker
|
|
|

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello friends this is ea take profit but not work in 4 digit broker
I would like it to work with my 4 digit brokers, can you help me?
where is the error? thank you
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int StopMultd=10;
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
double SL=NormalizeDouble(StopLoss*StopMultd,Digits);
//-------------------------------------------------------------------+
// orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
{
if((MonitorTakeProfit==true)&&(TakeProfit>0)&&(OrderMagicNumber()==0)){ // monitor tp
// Calculate take profit
double tpb=NormalizeDouble(OrderOpenPrice()+TP*Point,Digits);
double tps=NormalizeDouble(OrderOpenPrice()-TP*Point,Digits);
Comment("Modifying take profit");
if((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OrderSymbol()==Symbol())){ OrderModify(OrderTicket(),0,OrderStopLoss(),tpb,0,CLR_NONE); }
if((OrderType()==OP_SELL)&&(OrderTakeProfit()==0)&&(OrderSymbol()==Symbol())){ OrderModify(OrderTicket(),0,OrderStopLoss(),tps,0,CLR_NONE); }
} // monitor tp
if((MonitorStopLoss==true)&&(StopLoss>0)&&(OrderMagicNumber()==0)){ // monitor sl
// Calculate stop loss
double slb=NormalizeDouble(OrderOpenPrice()-SL*Point,Digits);
double sls=NormalizeDouble(OrderOpenPrice()+SL*Point,Digits);
Comment("Modifying stop loss");
if((OrderType()==OP_BUY)&&(OrderStopLoss()==0)&&(OrderSymbol()==Symbol())){ OrderModify(OrderTicket(),0,slb,OrderTakeProfit(),0,CLR_NONE); }
if((OrderType()==OP_SELL)&&(OrderStopLoss()==0)&&(OrderSymbol()==Symbol())){ OrderModify(OrderTicket(),0,sls,OrderTakeProfit(),0,CLR_NONE); }
}// monitor sl
Comment("");
}
}
}
//----
int Error=GetLastError();
if(Error==130){Alert("Wrong stops. Retrying."); RefreshRates();}
if(Error==133){Alert("Trading prohibited.");}
if(Error==2){Alert("Common error.");}
if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); RefreshRates();}
//----------
return(0);
}
//----------
//+-----------------------------------END-------------------------------+
//+---------------------------------------------------------------------+