Hi Coders, I'm a beginner of coding and no programming background.
FYI, I manually open the trades for my own testing only.
I created an EA to set SL (60 pips) &TP (1,400 pips) of open trades automatically on 1-digit, 2-digit, 3-digit, 4-digit and 5-digit symbols (including crypto BTCUSD) but partially failed, don't understand why. Problems :-
1) Some of the trades are successfully and correctly assigned with SL & TP buy majority of the symbols are not assigned with SL & TP at all.
2) My settings for SL=60 pips and TP=1,400 pips, some of the pairs are correctly set with 60 / 1,400 pips but some of the pairs are set with only 0.6 / 140 pips.
Attached for my EA, kindly run and have a look by manually open trades for 1-digit, 2-digit, 3-digit, 4-digit and 5-digit symbols.
FYI, my definition of pip and point levels are as follows :-
a) EU (5-digit) : 1.21689 >> 8=pip level and 9=point level
b) GJ (3-digit) : 153.489 >> 8=pip level and 9=point level
c) XAUUSD (2-digit) : 1735.89 >> 8=pip level and 9=point level
d) BTCUSD (2-digit) : 56143.89 >> 8=pip level and 9=point level
Hope someone can modify my EA and share to me on your mod, and hope can tell me where am I going wrong and with reasons so that I can learn. Thanks
FYI, I manually open the trades for my own testing only.
I created an EA to set SL (60 pips) &TP (1,400 pips) of open trades automatically on 1-digit, 2-digit, 3-digit, 4-digit and 5-digit symbols (including crypto BTCUSD) but partially failed, don't understand why. Problems :-
1) Some of the trades are successfully and correctly assigned with SL & TP buy majority of the symbols are not assigned with SL & TP at all.
2) My settings for SL=60 pips and TP=1,400 pips, some of the pairs are correctly set with 60 / 1,400 pips but some of the pairs are set with only 0.6 / 140 pips.
Inserted Code
extern double TPpip=1400.0; //TP in Pips extern double SLpip=60.0; //SL in Pips double cPoint=MarketInfo(Symbol(),MODE_POINT)*10; //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { for(int i=OrdersTotal()-1; i>=0; i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderStopLoss()==0 || (OrderTakeProfit()==0 && OrderStopLoss()==0)) { if(OrderType()==OP_BUY) { if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-SLpip*cPoint,OrderOpenPrice()+TPpip*cPoint,0,clrNONE)) Print("OrderModified BUY Error:",Symbol(),":",GetLastError()); } if(OrderType()==OP_SELL) { if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+SLpip*cPoint,OrderOpenPrice()-TPpip*cPoint,0,clrNONE)) Print("OrderModified SELL Error:",Symbol(),":",GetLastError()); } } }
Attached for my EA, kindly run and have a look by manually open trades for 1-digit, 2-digit, 3-digit, 4-digit and 5-digit symbols.
FYI, my definition of pip and point levels are as follows :-
a) EU (5-digit) : 1.21689 >> 8=pip level and 9=point level
b) GJ (3-digit) : 153.489 >> 8=pip level and 9=point level
c) XAUUSD (2-digit) : 1735.89 >> 8=pip level and 9=point level
d) BTCUSD (2-digit) : 56143.89 >> 8=pip level and 9=point level
Hope someone can modify my EA and share to me on your mod, and hope can tell me where am I going wrong and with reasons so that I can learn. Thanks
Attached File(s)
SetSLTP EA.mq4
2 KB
|
830 downloads