Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #property copyright "Copyright (c) 2018, Neetkun.io"
- #property link "https://neetkun.io/"
- #property version "1.0"
- // pips
- double currencyUnitPerPips(string symbol)
- {
- double digits = MarketInfo(symbol, MODE_DIGITS);
- double point = MarketInfo(symbol, MODE_POINT);
- double currencyUnit = 0.0;
- if(digits == 3.0 || digits == 5.0){
- currencyUnit = point * 10.0;
- } else {
- currencyUnit = point;
- }
- return currencyUnit;
- }
- // BestLot
- double BestLot(double lotpercent) {
- return NormalizeDouble(AccountBalance() * AccountInfoInteger(ACCOUNT_LEVERAGE) / Close[0] / 100000 * (lotpercent / 100), 2);
- }
- // TrailingStop
- int trailingPrice = 0;
- void TrailingStop(int ticket, double profit) {
- if(OrdersTotal() == 0) {
- trailingPrice = 0;
- }
- if (OrderSelect(ticket, SELECT_BY_TICKET) == true) {
- // 買い処理
- if (OrderType() == OP_BUY && OrderOpenPrice() < Bid) {
- if (trailingPrice > Bid - profit * Point) {
- OrderModify(OrderTicket(), OrderOpenPrice(), Bid - profit * Point, 0, 0, clrNONE);
- trailingPrice = Bid - profit * Point;
- }
- }
- // 売り処理
- if (OrderType() == OP_SELL && OrderOpenPrice() < Ask) {
- if (trailingPrice < Ask + profit * Point) {
- OrderModify(OrderTicket(), OrderOpenPrice(), Ask + profit * Point, 0, 0, clrNONE);
- trailingPrice = Ask + profit * Point;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement