-- Dodano: 30 sie 2018, 12:34 --
Zapomniałem dodać że jeśli będzie trzeba to oczywiście zapłacę

Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| EATime31082018.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern int MagicNumber = 100;
extern int Slippage = 3;
extern double LotSize = 0.1;
int counter = 0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
MqlTick lastTick;
if (Hour() > 7 && Hour() < 9) {
// open order
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iOpen(Symbol(), PERIOD_D1, 1)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
}
if (Hour() == 14) {
// close order
manuallyCloseOrder();
}
//Print( iOpen(Symbol(), PERIOD_D1, 1) );
//Print( iLow(Symbol(), PERIOD_D1, 1) );
//Print( iHigh(Symbol(), PERIOD_D1, 1) );
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {}
//+------------------------------------------------------------------+
void sendBuyOrder() {
if (OrdersTotal() > 0) return;
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, 0, 0,"Buy[" + counter +"]", MagicNumber, 0, clrGreen);
counter++;
}
void sendSellOrder() {
if (OrdersTotal() > 0) return;
OrderSend(Symbol(), OP_SELL, LotSize, Bid, Slippage, 0, 0,"Sell[" + counter +"]", MagicNumber, 0, clrRed);
counter++;
}
void manuallyCloseOrder() {
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS)==true) {
if (OrderType() == 0) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, clrNONE);
} else if (OrderType() == 1) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, clrNONE);
}
}
}
}
Kod: Zaznacz cały
if (Hour() > 7 && Hour() < 9) {
Kod: Zaznacz cały
void sendBuyOrder() {
if (OrdersTotal() > 0) return;
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, 0, 0,"Buy[" + counter +"]", MagicNumber, 0, clrGreen);
counter++;
}
Kod: Zaznacz cały
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iOpen(Symbol(), PERIOD_D1, 1)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
Kod: Zaznacz cały
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iClose(Symbol(), PERIOD_D1, 1)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
Kod: Zaznacz cały
if (Hour() == 14) {
// close order
manuallyCloseOrder();
}
Zła decyzja. Masz teraz weekend. Możesz pozmieniać godziny w tym krótkim kodzie i sprawdzić np otwarcie od 8 do 10, czyli o 9, a zamknięcie o 22 itd. Możesz dać inny instrument. Wyciągnąć z tego wnioski, wprowadzić potem poprawki, znaleźć bardziej optymalny wariant. Jak włączysz to na realnym rynku to stracisz czas zanim dostaniesz wyniki musisz czekać te kilka godzin, a żeby dostać wyniki w dłuższej serii zagrań, zobaczyć krzywą kapitału itp minął dni. Dlatego jest tester historyczny. I lepiej naucz się z niego korzystać jeśli jeszcze nie używałeś. Zrób ten plik tak jak napisałem, wrzuć ten kod do niego i potem na historii sprawdź jak w danym okresie zachowuje się dane ustawienie. Możesz przecież jeszcze sprawdzić otwieranie po cenie CLOSE bo dałem w przykładowym kodzie OPEN poprzedniej świecy.Zlepek pisze:Pięknie dziękuję. Wrzucam i będę kombinował. Nie wrzucę tego na historyczny bo to nie ma sensu. Nie cofnę się w przeszłość i nie odpalę go do zarabiania. Będzie testowany na realu ale spokojnie na mikrolotach
Kod: Zaznacz cały
if (Hour() > 7 && Hour() < 9) {
Kod: Zaznacz cały
if (Hour()== 18 ) {
Kod: Zaznacz cały
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iOpen(Symbol(), PERIOD_D1, 1)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
Kod: Zaznacz cały
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iOpen(Symbol(), PERIOD_H1, 3 )){
sendBuyOrder();
} else {
sendSellOrder();
Kod: Zaznacz cały
iOpen(Symbol(), PERIOD_H1, 0 )
Kod: Zaznacz cały
iOpen(Symbol(), PERIOD_H1, 3 )
SL i/lub TP ustawiasz w funkcji OrderSendCzy da się do tego podczepić jakoś SL ?
Kod: Zaznacz cały
double SL = 1.11111;
double TP = 1.22222;
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, SL , TP, "Buy[" + counter +"]", MagicNumber, 0, clrGreen);
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| EATime31082018_BetaTest2.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern int MagicNumber = 100;
extern int Slippage = 3;
extern double LotSize = 0.1;
int counter = 0;
extern int SL_POINT = 10;
extern int TP_POINT = 30;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
MqlTick lastTick;
/*
if (Hour() > 7 && Hour() < 9) {
// open order
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iClose(Symbol(), PERIOD_D1, 1)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
}
*/
if (Hour() == 18) {
// open order
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iClose(Symbol(), PERIOD_H1, 3)) {
//Print( iClose(Symbol(), PERIOD_H1, 3) );
double sl_price = iClose(Symbol(), PERIOD_H1, 3);
sendBuyOrder(sl_price);
} else {
//Print( iClose(Symbol(), PERIOD_H1, 3) );
double sl_price = iClose(Symbol(), PERIOD_H1, 3);
sendSellOrder(sl_price);
}
}
}
if (Hour() == 14) {
// close order
//manuallyCloseOrder();
}
//Print( iOpen(Symbol(), PERIOD_D1, 1) );
//Print( iLow(Symbol(), PERIOD_D1, 1) );
//Print( iHigh(Symbol(), PERIOD_D1, 1) );
//Print( "test" );
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {}
//+------------------------------------------------------------------+
/*
void sendBuyOrder() {
if (OrdersTotal() > 0) return;
double minstoplevel_SL = MarketInfo(Symbol(),MODE_STOPLEVEL)+SL_POINT*10;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double stoploss = NormalizeDouble(Bid-minstoplevel_SL*Point,Digits);
double takeprofit = NormalizeDouble(Bid+minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, stoploss, takeprofit,"Buy[" + counter +"]", MagicNumber, 0, clrGreen);
counter++;
}
void sendSellOrder() {
if (OrdersTotal() > 0) return;
double minstoplevel_SL = MarketInfo(Symbol(),MODE_STOPLEVEL)+SL_POINT*10;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double stoploss = NormalizeDouble(Ask+minstoplevel_SL*Point,Digits);
double takeprofit = NormalizeDouble(Ask-minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_SELL, LotSize, Bid, Slippage, stoploss, takeprofit,"Sell[" + counter +"]", MagicNumber, 0, clrRed);
counter++;
}
*/
void sendBuyOrder(double sl_price) {
if (OrdersTotal() > 0) return;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double takeprofit = NormalizeDouble(Bid+minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, sl_price, takeprofit,"Buy[" + counter +"]", MagicNumber, 0, clrGreen);
counter++;
}
void sendSellOrder(double sl_price) {
if (OrdersTotal() > 0) return;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double takeprofit = NormalizeDouble(Ask-minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_SELL, LotSize, Bid, Slippage, sl_price, takeprofit,"Sell[" + counter +"]", MagicNumber, 0, clrRed);
counter++;
}
void manuallyCloseOrder() {
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS)==true) {
if (OrderType() == 0) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, clrNONE);
} else if (OrderType() == 1) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, clrNONE);
}
}
}
}
Kod: Zaznacz cały
if (Hour() == 18) {
Kod: Zaznacz cały
if (Hour() == 18 && Minute() == 0) {
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| EATime31082018.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern int MagicNumber = 100;
extern int Slippage = 3;
extern double LotSize = 0.1;
int counter = 0;
extern int distance_between_HighLow_and_Stoploss = 0; // mozna tutaj przesunac stop loss w pipsach od jakiegos poziomu 10 = 1 pips
extern int SL_POINT = 65;
extern int TP_POINT = 97;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
MqlTick lastTick;
if (Hour() ==18 ) {
// open order
if(SymbolInfoTick(Symbol(),lastTick)) {
//Print( lastTick.bid );
if (lastTick.bid > iOpen(Symbol(), PERIOD_H1, 3)) {
sendBuyOrder();
} else {
sendSellOrder();
}
}
}
if (Hour() == 23) {
// close order
manuallyCloseOrder();
}
//Print( iOpen(Symbol(), PERIOD_D1, 1) );
//Print( iLow(Symbol(), PERIOD_D1, 1) );
//Print( iHigh(Symbol(), PERIOD_D1, 1) );
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {}
//+------------------------------------------------------------------+
void sendBuyOrder() {
if (OrdersTotal() > 0) return;
double minstoplevel_SL = MarketInfo(Symbol(),MODE_STOPLEVEL)+SL_POINT*10;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double stoploss = NormalizeDouble(Bid-minstoplevel_SL*Point,Digits);
double takeprofit = NormalizeDouble(Bid+minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, stoploss, takeprofit,"Buy[" + counter +"]", MagicNumber, 0, clrGreen);
counter++;
}
void sendSellOrder() {
if (OrdersTotal() > 0) return;
double minstoplevel_SL = MarketInfo(Symbol(),MODE_STOPLEVEL)+SL_POINT*10;
double minstoplevel_TP = MarketInfo(Symbol(),MODE_STOPLEVEL)+TP_POINT*10;
double stoploss = NormalizeDouble(Ask+minstoplevel_SL*Point,Digits);
double takeprofit = NormalizeDouble(Ask-minstoplevel_TP*Point,Digits);
OrderSend(Symbol(), OP_SELL, LotSize, Bid, Slippage, stoploss, takeprofit,"Sell[" + counter +"]", MagicNumber, 0, clrRed);
counter++;
}
void manuallyCloseOrder() {
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS)==true) {
if (OrderType() == 0) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, clrNONE);
} else if (OrderType() == 1) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, clrNONE);
}
}
}
}