Script untuk membuat modif TP
- Dapatkan gratis robot forex TraderSharing Di sini
Maksud dari modif TP adalah merubah TP secara otomatis dari pips yang di tentukan.
Ambil contoh :
saat OP pertama TP 10 pips
OP kedua martingel (lot 2x dari OP pertama} kemudian TP otomatis berpindah ke awal OP dan seterusnya.
Code pertama,Buat inputnya untuk pengaturan modif TP :
input int Tradersharing_TP = 10;
Code kedua di bawah input:
double tpbm,tpbo
Code ketiga:
if(Tradersharing_TP==0)tpbm=0;else tpbm=opbx+Tradersharing_TP*pt;
if(Tradersharing_TP==0)tpsm=0;else tpsm=opsx-Tradersharing_TP*pt;
if(Tradersharing_TP==0)tpsm=0;else tpsm=opsx-Tradersharing_TP*pt;
Code terakhir,masukan perintah modif TP nya :
void md(){int i,r;double tpnya,dtp;
for (i = 0; i < OrdersTotal(); i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
tpnya=OrderTakeProfit();}
for (i = OrdersTotal() - 1; i >= 0; i--) {if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol() != Symbol()) continue;
dtp=OrderTakeProfit();
if( tpnya!=dtp)r=OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), tpnya, 0, CLR_NONE); }}
for (i = 0; i < OrdersTotal(); i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
tpnya=OrderTakeProfit();}
for (i = OrdersTotal() - 1; i >= 0; i--) {if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol() != Symbol()) continue;
dtp=OrderTakeProfit();
if( tpnya!=dtp)r=OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), tpnya, 0, CLR_NONE); }}
Code lengkapnya:
.//+------------------------------------------------------------------+
//| tradersharing.com.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright Tradersharing comunity."
#property link "https://www.tradersharing.com"
#property version "1.00"
#property strict
input string Nama EA ="tradersharing";
input string Website = "www.tradersharing.com";
input string Contact = "admin@tradersharing.com";
input string blog ="boronglagi.blogspot.com";
input int Tradersharing_TP = 10; //---code pertama masukan di sini
double tpbm,tpbo //---Code kedua
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//---code ketiga di sini
if(Tradersharing_TP==0)tpbm=0;else tpbm=opbx+Tradersharing_TP*pt;if(Tradersharing_TP==0)tpsm=0;else tpsm=opsx-Tradersharing_TP*pt;
//+------------------------------------------------------------------+
//---Masukan perintah modif TP persis di bawah ini ya
//| tradersharing.com.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright Tradersharing comunity."
#property link "https://www.tradersharing.com"
#property version "1.00"
#property strict
input string Nama EA ="tradersharing";
input string Website = "www.tradersharing.com";
input string Contact = "admin@tradersharing.com";
input string blog ="boronglagi.blogspot.com";
input int Tradersharing_TP = 10; //---code pertama masukan di sini
double tpbm,tpbo //---Code kedua
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//---code ketiga di sini
if(Tradersharing_TP==0)tpbm=0;else tpbm=opbx+Tradersharing_TP*pt;if(Tradersharing_TP==0)tpsm=0;else tpsm=opsx-Tradersharing_TP*pt;
//+------------------------------------------------------------------+
//---Masukan perintah modif TP persis di bawah ini ya
void md(){int i,r;double tpnya,dtp;
for (i = 0; i < OrdersTotal(); i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
tpnya=OrderTakeProfit();}
for (i = OrdersTotal() - 1; i >= 0; i--) {if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol() != Symbol()) continue;
dtp=OrderTakeProfit();
if( tpnya!=dtp)r=OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), tpnya, 0, CLR_NONE); }}
for (i = 0; i < OrdersTotal(); i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
tpnya=OrderTakeProfit();}
for (i = OrdersTotal() - 1; i >= 0; i--) {if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol() != Symbol()) continue;
dtp=OrderTakeProfit();
if( tpnya!=dtp)r=OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), tpnya, 0, CLR_NONE); }}
& Home Trader