Jump to content

EA - UPSTREAM


saendee

Recommended Posts

Software Deals of the Week: September 7-14

 

MetaTrader Expert Advisor UPSTREAM Portfolio

 

Currency: EUR/JPY, EURUSD, GBPUSD, AUDUSD

Timeframe: H1

Using Indicators: Moving Averages

Trading Time: Round-the-clock

Risk: Medium

Minimum Deposit: $1000

Recommended Deposit:$3000

Orders Type:BUY and SELL market orders

Concept:Superposition of market fluctuations

Money Management:Stop Loss and Take Profit, position reversal

Customization:possible upon the request

 

Learn more about this expert advisor and view backtests

 

MetaTrader 4 Upstream Portfolio Monitoring page

days: 181

Change Equity: 94%

Balance: 62541.57

 

Click to view monitoring page

 

Regular price for Upstream Portfolio: 469.95USD

Price with extra discount (limited time offer): 399 USD, BUY NOW!

 

Best regards,

BJF Trading Group inc.

Link to comment
Share on other sites

Re: EA - UPSTREAM

 

Hi,

 

I cannot get Upstream to work profitable. Is it made for 4 Digits Broker?

 

THX, Fran

 

 

Edited to work on any digit broker 4 or five digit.

 

Kudo's please...lol

 

///////////////////////////////////////////////////// Copy From down

 

#property copyright "© 2007"

#property link ""

 

 

#include <stdlib.mqh>

#include <stderror.mqh>

 

#define major 4

#define minor 0

 

extern string _tmp1_ = " --- ---";

extern double Lots = 0.1;

extern int StopLoss = 140;

extern int TakeProfit = 180;

extern int Slippage = 3;

extern int Magic = 050107;

 

extern string _tmp2_ = " --- ---";

extern color clBuy = DodgerBlue;

extern color clSell = Crimson;

 

extern string _tmp3_ = " --- ---";

extern int FastMA.Period = 47;

extern int FastMA.ma_shift = 4;

extern int FastMA.ma_method = MODE_EMA;

extern int FastMA.applied_price = PRICE_CLOSE;

extern int SlowMA.Period = 5;

extern int SlowMA.ma_shift = 16;

extern int SlowMA.ma_method = MODE_EMA;

extern int SlowMA.applied_price = PRICE_CLOSE;

extern int MA.bar = 1;

double pointvalue;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

void init () {

if (Digits == 4 || Digits == 2) pointvalue = Point;

else if (Digits == 5 || Digits == 3) pointvalue =Point * 10.0 ;

 

 

}

 

void deinit() {

 

}

 

void start() {

 

//-----

 

//if (!IsTesting()) return;

 

if (false)

if (OrdersCount0() > 0) return;

 

//-----

 

double SlowMA0 = iMA(NULL, 0, SlowMA.Period, SlowMA.ma_shift, SlowMA.ma_method, SlowMA.applied_price, MA.bar);

double FastMA0 = iMA(NULL, 0, FastMA.Period, FastMA.ma_shift, FastMA.ma_method, FastMA.applied_price, MA.bar);

double SlowMA1 = iMA(NULL, 0, SlowMA.Period, SlowMA.ma_shift, SlowMA.ma_method, SlowMA.applied_price, MA.bar+1);

double FastMA1 = iMA(NULL, 0, FastMA.Period, FastMA.ma_shift, FastMA.ma_method, FastMA.applied_price, MA.bar+1);

 

 

//Print("* ", FastMA1, " ", SlowMA1, " ", FastMA0, " ", SlowMA0, " ", RSI);

//Print("* ", FastMA1, " ", FastMA0);

//Print("! ", Close[1], " ", Close[0]);

//return;

 

if (DayOfWeek() == 5) return;

 

 

//-----

 

int BuyCnt = 0;

int SellCnt = 0;

 

int cnt = OrdersTotal();

for (int i=0; i < cnt; i++) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != Magic) continue;

 

int type = OrderType();

if (type == OP_BUY) BuyCnt++;

if (type == OP_SELL) SellCnt++;

}

 

//-----

 

 

double price, sl, tp;

 

if (FastMA1 <= SlowMA1 && FastMA0 > SlowMA0)

{

if (BuyCnt > 0) return;

 

if (SellCnt > 0) {

SellCnt = CloseOrders(OP_SELL);

if (SellCnt > 0) return;

}

 

{

price = Ask;

 

sl = 0;

tp = 0;

if (StopLoss > 0) sl = price - StopLoss*pointvalue;

if (TakeProfit > 0) tp = price + TakeProfit*pointvalue;

 

Buy(Symbol(), GetLots(), price, sl, tp, Magic);

}

 

return;

}

 

if (FastMA1 >= SlowMA1 && FastMA0 < SlowMA0)

{

if (DayOfWeek() == 3) return;

if (SellCnt > 0) return;

 

if (BuyCnt > 0) {

BuyCnt = CloseOrders(OP_BUY);

if (BuyCnt > 0) return;

}

 

{

price = Bid;

 

sl = 0;

tp = 0;

if (StopLoss > 0) sl = price + StopLoss*pointvalue;

if (TakeProfit > 0) tp = price - TakeProfit*pointvalue;

 

Sell(Symbol(), GetLots(), price, sl, tp, Magic);

}

 

return;

}

}

 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

double GetLots() {

return (Lots);

}

 

int CloseOrders(int type) {

 

int cnt = OrdersTotal();

for (int i=cnt-1; i >= 0; i--) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != Magic) continue;

 

if (OrderType() != type) continue;

 

if (OrderType() == OP_BUY) {

CloseOrder(OrderTicket(), OrderLots(), Bid);

}

else if (OrderType() == OP_SELL) {

CloseOrder(OrderTicket(), OrderLots(), Ask);

}

}

 

int orders = 0;

cnt = OrdersTotal();

for (i = 0; i < cnt; i++) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != Magic) continue;

 

if (OrderType() == type) orders++;

}

 

return (orders);

}

 

int OrdersCount0()

{

int orders = 0;

 

int cnt = OrdersTotal();

for (int i=0; i<cnt; i++) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;

 

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != Magic) continue;

 

if (OrderOpenTime() >= Time[0]) orders++;

}

 

cnt = OrdersHistoryTotal();

for (i=0; i<cnt; i++) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;

 

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != Magic) continue;

 

if (OrderOpenTime() >= Time[0]) orders++;

}

 

return (orders);

}

 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

int SleepOk = 2000;

int SleepErr = 6000;

 

int Buy(string symbol, double lot, double price, double sl, double tp, int magic, string comment="") {

RefreshRates();

int dig = MarketInfo(symbol, MODE_DIGITS);

 

price = NormalizeDouble(price, dig);

sl = NormalizeDouble(sl, dig);

tp = NormalizeDouble(tp, dig);

 

string _lot = DoubleToStr(lot, 1);

string _price = DoubleToStr(price, dig);

string _sl = DoubleToStr(sl, dig);

string _tp = DoubleToStr(tp, dig);

 

Print("Buy \"", symbol, "\", ", _lot, ", ", _price, ", ", Slippage, ", ", _sl, ", ", _tp, ", ", magic, ", \"", comment, "\"");

 

int res = OrderSend(symbol, OP_BUY, lot, price, Slippage, sl, tp, comment, magic, 0, clBuy);

if (res >= 0) {

Sleep(SleepOk);

return (res);

}

 

int code = GetLastError();

Print("Error opening BUY order: ", ErrorDescription(code), " (", code, ")");

Sleep(SleepErr);

 

return (-1);

}

 

int Sell(string symbol, double lot, double price, double sl, double tp, int magic, string comment="") {

RefreshRates();

int dig = MarketInfo(symbol, MODE_DIGITS);

 

price = NormalizeDouble(price, dig);

sl = NormalizeDouble(sl, dig);

tp = NormalizeDouble(tp, dig);

 

string _lot = DoubleToStr(lot, 1);

string _price = DoubleToStr(price, dig);

string _sl = DoubleToStr(sl, dig);

string _tp = DoubleToStr(tp, dig);

 

Print("Sell \"", symbol, "\", ", _lot, ", ", _price, ", ", Slippage, ", ", _sl, ", ", _tp, ", ", magic, ", \"", comment, "\"");

 

int res = OrderSend(symbol, OP_SELL, lot, price, Slippage, sl, tp, comment, magic, 0, clSell);

if (res >= 0) {

Sleep(SleepOk);

return (res);

}

 

int code = GetLastError();

Print("Error opening SELL order: ", ErrorDescription(code), " (", code, ")");

Sleep(SleepErr);

 

return (-1);

}

 

bool CloseOrder(int ticket, double lot, double price) {

 

RefreshRates();

if (!OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) return(false);

int dig = MarketInfo(OrderSymbol(), MODE_DIGITS);

 

string _lot = DoubleToStr(lot, 1);

string _price = DoubleToStr(price, dig);

 

Print("CloseOrder ", ticket, ", ", _lot, ", ", _price, ", ", Slippage);

 

bool res = OrderClose(ticket, lot, price, Slippage);

if (res) {

Sleep(SleepOk);

return (res);

}

 

int code = GetLastError();

Print("CloseOrder failed: ", ErrorDescription(code), " (", code, ")");

Sleep(SleepErr);

 

return (false);

}

 

/////////////////////////////////////////// End

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...