A masz zdrowie, i koncentrację, żeby wszystkie wyłapać?
Daj spokój, jest dobrze!
A masz zdrowie, i koncentrację, żeby wszystkie wyłapać?
Kod: Zaznacz cały
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
public class Strategy_H4Agresive500leverage1 implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private IAccount account;
private IOrder order;
private int counter = 0;
private int ORDER_LIMIT = 100;
public double amount = 1; // 1 lot
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
}
public void onAccount(IAccount account) throws JFException {
this.account = account;
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
private boolean start_trade = false;
private boolean lock_trade = false;
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
Date date = new Date(bidBar.getTime());
// jeśli M15 poprzednia i aktualan są bycze to kupuj, jeśli nie to stop
IBar m15 = history.getBar(instrument, Period.FIFTEEN_MINS, OfferSide.BID, 1); // prev
// jeśli m5 jest odwrotna, bear realizuj zysk
IBar m5 = history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, 1); // prev
if (isBullBar(m15)) {
start_trade = true;
} else {
start_trade = false;
}
if (date.getDay() != 6 && date.getDay() != 7 && bidBar.getVolume() != 0) {
if (start_trade) {
if (date.getHours() == 13) {
sendOrder(instrument, OrderCommand.BUY);
}
}
}
boolean new_eq = (account.getBalance() * 0.5 + account.getBalance()) <= account.getEquity() ? true : false; // 50% SLK
print((account.getBalance() * 0.5 + account.getBalance()) + " " + account.getEquity());
if (new_eq) {
start_trade = false;
closeOrders();
lock_trade = true;
}
if (date.getHours() == 17 /*|| new_eq*/) {
closeOrders();
}
// reset
if (period.equals(Period.DAILY)) {
reset();
}
}
public boolean isBullBar(IBar bar) {
return bar.getOpen() > bar.getClose() ? false : true;
}
public void reset() {
lock_trade = false;
}
public void sendOrder(Instrument instrument, OrderCommand orderCommand) throws JFException {
if (engine.getOrders(instrument).size() > ORDER_LIMIT) return;
if (lock_trade) return;
order = engine.submitOrder(getLabel(instrument), instrument, orderCommand, amount);
order.waitForUpdate(2000);
}
public void closeOrders() throws JFException {
if (engine.getOrders().size() == 0) return;
for (IOrder order : engine.getOrders()) {
order.close();
}
}
protected String getLabel(Instrument instrument) {
String label = instrument.name() + System.currentTimeMillis() + (counter++);
label = label.toUpperCase();
return label;
}
public void print(Object o) {
console.getOut().println(o);
}
}
Ktoś kiedyś tutaj napisał, że wystarczy "wziąć kawałek z tego tortu" i to wystarczy, czyli nie próbować złapać całego ruchu od dołka do szczytu każdego dnia, tylko systematycznie kawałek po kawałku z całego ruchu... małą łyżeczką itd.rookie2 pisze: ↑29 sie 2021, 22:56Witam. Jeśli mam z kimś niedokończone sprawy, odezwę się niedługo. Potrzebowałem przerwy od fx i od tego wszystkiego. Niedługo zrobię kolejne podejście. Tym razem będę rozgrywał jakieś świece, chyba głównie H4 i ostro piramidował dodatnio. Czyli wykorzystywał wysoki lewar do maksimum (ale też bez przesady bo jednak przy 1:500 takie podejście szybko wykańcza konto w dukascopy). Tutaj 2 zrzuty pokazujące wejścia w oparciu o świece H4 na DAX tylko na BUY o 13 GMT i wyjście o 17 GMT. Pierwszy obrazek to test na dźwigni 1:30. Nie było "free margin" żeby otworzył kolejne pozycje, ale jeśli lewar jest wyższy te niewielkie ruchy na H4 itp można wykorzystać. Innymi słowy przewaga będzie polegać na tym że szukam właśnie tego typu "patternów" świecowych np na DAX często o 13 GMT jest wzrostowa H4 i stawiał na to, a zarządzanie kapitałem to agresywne piramidowanie i wykorzystywanie tej chwilowej przewagi, tego ruchu na maksa.
Chart_DEU.IDX_EUR_4 Hours_snapshot.png
Drugi obrazek pokazuje wejście na dźwigni 1:200, ale w Dukascopy można otwierać mikroloty 0.1, w IC Markets tylko 1 lot, ale tam jest dźwignia 1:500. W każdym razie na dźwigni 1:200 przy podejściu do realizowania zysku +50% wygląda to mniej więcej tak. Depozyt początkowy 200$.
Chart_DEU.IDX_EUR_30 Mins_snapshot.png
Prosty test kodDopiero będę powoli wracał po tej krótkiej przerwie do fx, dopracowywał strategie itd. Niedługo się odezwę...Kod: Zaznacz cały
package jforex; import java.util.*; import com.dukascopy.api.*; import com.dukascopy.api.IEngine.OrderCommand; public class Strategy_H4Agresive500leverage1 implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface; private IAccount account; private IOrder order; private int counter = 0; private int ORDER_LIMIT = 100; public double amount = 1; // 1 lot public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface(); } public void onAccount(IAccount account) throws JFException { this.account = account; } public void onMessage(IMessage message) throws JFException { } public void onStop() throws JFException { } public void onTick(Instrument instrument, ITick tick) throws JFException { } private boolean start_trade = false; private boolean lock_trade = false; public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { Date date = new Date(bidBar.getTime()); // jeśli M15 poprzednia i aktualan są bycze to kupuj, jeśli nie to stop IBar m15 = history.getBar(instrument, Period.FIFTEEN_MINS, OfferSide.BID, 1); // prev // jeśli m5 jest odwrotna, bear realizuj zysk IBar m5 = history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, 1); // prev if (isBullBar(m15)) { start_trade = true; } else { start_trade = false; } if (date.getDay() != 6 && date.getDay() != 7 && bidBar.getVolume() != 0) { if (start_trade) { if (date.getHours() == 13) { sendOrder(instrument, OrderCommand.BUY); } } } boolean new_eq = (account.getBalance() * 0.5 + account.getBalance()) <= account.getEquity() ? true : false; // 50% SLK print((account.getBalance() * 0.5 + account.getBalance()) + " " + account.getEquity()); if (new_eq) { start_trade = false; closeOrders(); lock_trade = true; } if (date.getHours() == 17 /*|| new_eq*/) { closeOrders(); } // reset if (period.equals(Period.DAILY)) { reset(); } } public boolean isBullBar(IBar bar) { return bar.getOpen() > bar.getClose() ? false : true; } public void reset() { lock_trade = false; } public void sendOrder(Instrument instrument, OrderCommand orderCommand) throws JFException { if (engine.getOrders(instrument).size() > ORDER_LIMIT) return; if (lock_trade) return; order = engine.submitOrder(getLabel(instrument), instrument, orderCommand, amount); order.waitForUpdate(2000); } public void closeOrders() throws JFException { if (engine.getOrders().size() == 0) return; for (IOrder order : engine.getOrders()) { order.close(); } } protected String getLabel(Instrument instrument) { String label = instrument.name() + System.currentTimeMillis() + (counter++); label = label.toUpperCase(); return label; } public void print(Object o) { console.getOut().println(o); } }
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| icmarkets_demo1.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
// DAX
// okres 1 testu 06.09.2021 - 20.09.2021 - SELL
// okres 2 testu 16.08.2021 - 27.08.2021 - BUY
int counter = 0;
bool block_trade = false;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
int day = DayOfWeek();
Print(day);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//if (DayOfWeek() == 3) {
//
Print(AccountFreeMargin() + " ---> " + AccountMargin() + " " + (AccountEquity() / 2) + " [equity] " + AccountEquity());
//Print(AccountFreeMargin() + " " + AccountMargin());
sendOrder();
if (Hour() == 18 && Minute() == 30) {
block_trade = true;
closeOrder();
}
if (Hour() == 1) {
block_trade = false;
}
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//---
double ret=0.0;
//---
//---
return(ret);
}
//+------------------------------------------------------------------+
void sendOrder() {
//
if (AccountMargin() < (AccountEquity() / 2)) {
if (Hour() >= 16 && (!block_trade)) {
//if (Bid > iOpen("DE30",PERIOD_W1,0)) {
// sell
OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"My order",16384,0,clrNONE);
//} else {
// buy
//OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"My order",16384,0,clrNONE);
// }
}
}
}
void closeOrder() {
int ticket;
if (OrdersTotal()==0) return;
for (int i=OrdersTotal()-1; i>=0; i--)
{//pozicio kivalasztasa
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)//ha kivalasztas ok
{
if ( Symbol() == OrderSymbol() )
{
//Print ("order ticket: ", OrderTicket(), "order magic: ", OrderMagicNumber());
if (OrderType()==0)
{//ha long
ticket=OrderClose(OrderTicket(),OrderLots(), MarketInfo(OrderSymbol(),MODE_BID), 3,clrNONE);
if (ticket==-1) Print ("Error: ", GetLastError());
if (ticket>0) Print ("Position ", OrderTicket() ," closed. Thank you for using our script! Visit www.think-trust-trade.com for more free tools.");
}
if (OrderType()==1)
{//ha short
ticket=OrderClose(OrderTicket(),OrderLots(), MarketInfo(OrderSymbol(),MODE_ASK), 3,clrNONE);
if (ticket==-1) Print ("Error: ", GetLastError());
if (ticket>0) Print ("Position ", OrderTicket() ," closed. Thank you for using our script! Visit www.think-trust-trade.com for more free tools.");
}
}
}
//Print(Symbol() == OrderSymbol());
}//pozicio kivalszatas vege
//----
//return(0);
}
To czy strategia+trader zarabia nie zalezy od kwoty depo. Jesli nie zarabia to dotyczy każdej kwoty. Nawet tych największych. Rynek forex jest tak płynny, że wchłonie każdą ilość pieniędzy. Ktoś tu pisał, że 100 lotów to dla rynku jakiś problem. Niezły ubaw