Modem TP-LINK TL-MR3420
Mikrotik RB750

buat script (system->scripts)
trus buat scheduler (system->scheduler)
set tiap 15 menit

#cek google dengan ping, kalau ga konek maka restart modem
:if ([/ping 8.8.8.8 interval=3 count=5]=0) do={:log info "Internet down";/tool fetch mode=http user="admin" password="admin" url="http://192.168.0.1/userRpm/SysRebootRpm.htm?Reboot=Reboot";/file remove [find name~"SysReboot"]; }
#else={:log info "Internet Up";}

silahkan dimasukkan di strategy tester Metatrader 4 atau dicoba di acc demo,
hasilnya baik atau buruk adalah tanggung jawab Anda bukan Saya, lha wong saya cuma iseng buatnya

Pair: EURUSD
TimeFrame: H4

#property copyright “Copyright ¬© 2013, Okho Bayu Wantoro”
#property link http://www.Okhomedia.com

//—- input parameters
double Lots=30;
extern double BalancePerLots = 350;// aman di 300
extern int TakeProfit=70;
extern int StopLoss=50;
extern string Ma1=”MA BESAR”;
extern int Ma1Period=50;
extern int Ma1Shift=0;
extern int Ma1Method=0;
extern int Ma1AppliedPrice=4;
extern string Ma2=”MA KECIL”;
extern int Ma2Period=20;
extern int Ma2Shift=0;
extern int Ma2Method=0;
extern int Ma2AppliedPrice=4;
extern int MagicNumber=696969;

double time_ea_start;

string Trend;

int init()
{
//SETINGAN BEBAS
BalancePerLots = 150;

//150 OK Juga, 500 atau 1000 aman
//shit!! its crazy tune, klo 30 = 37x in 4 bulan dari 1 januari 2013 s/d 30 april 2013, cobain aja

TakeProfit=70;

StopLoss=50;

return (0);
}
int start()
{
int StopMultd,Slip=5;
int halt1 = 0;
StopMultd=10;

double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
// stop loss
double SL=NormalizeDouble(StopLoss*StopMultd,Digits);

double Slippage=NormalizeDouble(Slip*StopMultd,Digits);

// Ma strategy one
double MA1_bc=iMA(Symbol(),PERIOD_H4,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,0);
double MA1_bd=iMA(Symbol(),PERIOD_H4,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,3);
double MA1_be=iMA(Symbol(),PERIOD_H4,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,5);

// Ma constant
double MA2_bc=iMA(Symbol(),PERIOD_H4,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,0);
double MA2_bd=iMA(Symbol(),PERIOD_H4,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,3);
double MA2_be=iMA(Symbol(),PERIOD_H4,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,5);

//——————————————————————-+
//Check open orders
//——————————————————————-+
if(OrdersTotal()>0){
for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
{
if(OrderMagicNumber()==MagicNumber&&OrderSymbol()==Symbol()) {halt1=1;}

}
}
}
//——————————————————————-+

//——————————————————————-+
// trading strategy
//——————————————————————-+

//SET LOTS BASED ON CURRENT BALANCE, BIGGER IS HIGHER
Lots = AccountBalance() / BalancePerLots;

if(halt1!=1){// halt1

// Sell criteria
if ((MA1_bc>=MA2_bc)&&(MA1_bd<MA2_bd)&&(MA1_be<MA2_be)&&Trend!=”SELL”) //Signal Sell

{
int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,”OKHO EA MA_CROSS”,MagicNumber,0,Green);
if(opensell<1){int sellfail=1;}
Trend=”SELL”;
}

// Buy criteria
if ((MA1_bc<=MA2_bc)&&(MA1_bd>MA2_bd)&&(MA1_be>MA2_be)&&Trend!=”BUY”) //Signal Buy
{
int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,”OKHO EA MA_CROSS”,MagicNumber,0,Blue);
if(openbuy<1){int buyfail=1;}
Trend=”BUY”;
}

}// halt1

//—————————————————————————————————–
if(OrdersTotal()>0){
for(i=1; i<=OrdersTotal(); i++){ // Cycle searching in orders

if (OrderSelect(i-1,SELECT_BY_POS)==true){ // If the next is available

// Calculate take profit
double tpb=NormalizeDouble(OrderOpenPrice()+TP*Point,Digits);
double tps=NormalizeDouble(OrderOpenPrice()-TP*Point,Digits);
// Calculate stop loss
double slb=NormalizeDouble(OrderOpenPrice()-SL*Point,Digits);
double sls=NormalizeDouble(OrderOpenPrice()+SL*Point,Digits);

if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_BUY)&&(OrderTakeProfit()==0||OrderStopLoss()==0)&&OrderSymbol()==Symbol()) { OrderModify(OrderTicket(),0,slb,tpb,0,CLR_NONE); }
if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_SELL)&&(OrderTakeProfit()==0||OrderStopLoss()==0)&&OrderSymbol()==Symbol()) { OrderModify(OrderTicket(),0,sls,tps,0,CLR_NONE); }

}
}
}

//——————————————————————-+
// Error processing
//——————————————————————-+
if(buyfail==1||sellfail==1){
Print (error(GetLastError()));
Sleep(500); RefreshRates();
}

//——————————————————————-
return(0);
}

string error(int err)
{

string error_string;

switch(err)
{
//—- codes returned from trade server
case 0:
case 1: error_string=”no error”; break;
case 2: error_string=”common error”; break;
case 3: error_string=”invalid trade parameters”; break;
case 4: error_string=”trade server is busy”; break;
case 5: error_string=”old version of the client terminal”; break;
case 6: error_string=”no connection with trade server”; break;
case 7: error_string=”not enough rights”; break;
case 8: error_string=”too frequent requests”; break;
case 9: error_string=”malfunctional trade operation (never returned error)”; break;
case 64: error_string=”account disabled”; break;
case 65: error_string=”invalid account”; break;
case 128: error_string=”trade timeout”; break;
case 129: error_string=”invalid price”; break;
case 130: error_string=”invalid stops”; break;
case 131: error_string=”invalid trade volume”; break;
case 132: error_string=”market is closed”; break;
case 133: error_string=”trade is disabled”; break;
case 134: error_string=”not enough money”; break;
case 135: error_string=”price changed”; break;
case 136: error_string=”off quotes”; break;
case 137: error_string=”broker is busy (never returned error)”; break;
case 138: error_string=”requote”; break;
case 139: error_string=”order is locked”; break;
case 140: error_string=”long positions only allowed”; break;
case 141: error_string=”too many requests”; break;
case 145: error_string=”modification denied because order too close to market”; break;
case 146: error_string=”trade context is busy”; break;
case 147: error_string=”expirations are denied by broker”; break;
case 148: error_string=”amount of open and pending orders has reached the limit”; break;
case 149: error_string=”hedging is prohibited”; break;
case 150: error_string=”prohibited by FIFO rules”; break;
//—- mql4 errors
case 4000: error_string=”no error (never generated code)”; break;
case 4001: error_string=”wrong function pointer”; break;
case 4002: error_string=”array index is out of range”; break;
case 4003: error_string=”no memory for function call stack”; break;
case 4004: error_string=”recursive stack overflow”; break;
case 4005: error_string=”not enough stack for parameter”; break;
case 4006: error_string=”no memory for parameter string”; break;
case 4007: error_string=”no memory for temp string”; break;
case 4008: error_string=”not initialized string”; break;
case 4009: error_string=”not initialized string in array”; break;
case 4010: error_string=”no memory for array\’ string”; break;
case 4011: error_string=”too long string”; break;
case 4012: error_string=”remainder from zero divide”; break;
case 4013: error_string=”zero divide”; break;
case 4014: error_string=”unknown command”; break;
case 4015: error_string=”wrong jump (never generated error)”; break;
case 4016: error_string=”not initialized array”; break;
case 4017: error_string=”dll calls are not allowed”; break;
case 4018: error_string=”cannot load library”; break;
case 4019: error_string=”cannot call function”; break;
case 4020: error_string=”expert function calls are not allowed”; break;
case 4021: error_string=”not enough memory for temp string returned from function”; break;
case 4022: error_string=”system is busy (never generated error)”; break;
case 4050: error_string=”invalid function parameters count”; break;
case 4051: error_string=”invalid function parameter value”; break;
case 4052: error_string=”string function internal error”; break;
case 4053: error_string=”some array error”; break;
case 4054: error_string=”incorrect series array using”; break;
case 4055: error_string=”custom indicator error”; break;
case 4056: error_string=”arrays are incompatible”; break;
case 4057: error_string=”global variables processing error”; break;
case 4058: error_string=”global variable not found”; break;
case 4059: error_string=”function is not allowed in testing mode”; break;
case 4060: error_string=”function is not confirmed”; break;
case 4061: error_string=”send mail error”; break;
case 4062: error_string=”string parameter expected”; break;
case 4063: error_string=”integer parameter expected”; break;
case 4064: error_string=”double parameter expected”; break;
case 4065: error_string=”array as parameter expected”; break;
case 4066: error_string=”requested history data in update state”; break;
case 4099: error_string=”end of file”; break;
case 4100: error_string=”some file error”; break;
case 4101: error_string=”wrong file name”; break;
case 4102: error_string=”too many opened files”; break;
case 4103: error_string=”cannot open file”; break;
case 4104: error_string=”incompatible access to a file”; break;
case 4105: error_string=”no order selected”; break;
case 4106: error_string=”unknown symbol”; break;
case 4107: error_string=”invalid price parameter for trade function”; break;
case 4108: error_string=”invalid ticket”; break;
case 4109: error_string=”trade is not allowed in the expert properties”; break;
case 4110: error_string=”longs are not allowed in the expert properties”; break;
case 4111: error_string=”shorts are not allowed in the expert properties”; break;
case 4200: error_string=”object is already exist”; break;
case 4201: error_string=”unknown object property”; break;
case 4202: error_string=”object is not exist”; break;
case 4203: error_string=”unknown object type”; break;
case 4204: error_string=”no object name”; break;
case 4205: error_string=”object coordinates error”; break;
case 4206: error_string=”no specified subwindow”; break;
default: error_string=”unknown error”;
}

return(error_string);
}

HASILNYA

Symbol EURUSD (Euro vs US Dollar)
Period 4 Hours (H4) 2013.01.02 08:00 – 2013.05.01 20:00 (2013.01.01 – 2013.05.02)
Model Every tick (the most precise method based on all available least timeframes)
Parameters BalancePerLots=350; TakeProfit=70; StopLoss=50; Ma1=”MA BESAR”; Ma1Period=50; Ma1Shift=0; Ma1Method=0; Ma1AppliedPrice=4; Ma2=”MA KECIL”; Ma2Period=20; Ma2Shift=0; Ma2Method=0; Ma2AppliedPrice=4; MagicNumber=696969;
Bars in test 1516 Ticks modelled 1918549 Modelling quality 60.51%
Mismatched charts errors 2
Initial deposit 10000.00
Total net profit 83558.37 Gross profit 101034.71 Gross loss -17476.34
Profit factor 5.78 Expected payoff 8355.84
Absolute drawdown 346.63 Maximal drawdown 27641.90 (38.58%) Relative drawdown 53.62% (15247.96)
Total trades 10 Short positions (won %) 5 (80.00%) Long positions (won %) 5 (80.00%)
Profit trades (% of total) 8 (80.00%) Loss trades (% of total) 2 (20.00%)
Largest profit trade 29768.20 loss trade -10147.17
Average profit trade 12629.34 loss trade -8738.17
Maximum consecutive wins (profit in money) 4 (73202.01) consecutive losses (loss in money) 1 (-10147.17)
Maximal consecutive profit (count of wins) 73202.01 (4) consecutive loss (count of losses) -10147.17 (1)
Average consecutive wins 3 consecutive losses 1

StrategyTester_BLOG

# Time Type Order Size Price S / L T / P Profit Balance
1 2013.01.03 04:00 sell 1 66.66 1.31695 0.00000 0.00000
2 2013.01.03 04:00 modify 1 66.66 1.31695 1.32195 1.30995
3 2013.01.03 12:49 t/p 1 66.66 1.30995 1.32195 1.30995 4666.20 14666.20
4 2013.01.11 12:00 buy 2 97.77 1.32744 0.00000 0.00000
5 2013.01.11 12:00 modify 2 97.77 1.32744 1.32244 1.33444
6 2013.01.11 15:39 t/p 2 97.77 1.33444 1.32244 1.33444 6843.90 21510.10
7 2013.01.23 04:00 sell 3 143.40 1.33160 0.00000 0.00000
8 2013.01.23 04:00 modify 3 143.40 1.33160 1.33660 1.32460
9 2013.01.24 17:08 s/l 3 143.40 1.33660 1.33660 1.32460 -7329.17 14180.93
10 2013.01.25 04:00 buy 4 94.53 1.33602 0.00000 0.00000
11 2013.01.25 04:00 modify 4 94.53 1.33602 1.33102 1.34302
12 2013.01.25 11:03 t/p 4 94.53 1.34302 1.33102 1.34302 6617.10 20798.03
13 2013.02.07 15:48 sell 5 138.65 1.34852 0.00000 0.00000
14 2013.02.07 15:48 modify 5 138.65 1.34852 1.35352 1.34152
15 2013.02.07 17:07 t/p 5 138.65 1.34152 1.35352 1.34152 9705.50 30503.53
16 2013.03.12 16:00 buy 6 203.35 1.30409 0.00000 0.00000
17 2013.03.12 16:00 modify 6 203.35 1.30409 1.29909 1.31109
18 2013.03.13 15:31 s/l 6 203.35 1.29909 1.29909 1.31109 -10147.17 20356.36
19 2013.03.13 15:31 sell 7 135.70 1.29908 0.00000 0.00000
20 2013.03.13 15:31 modify 7 135.70 1.29908 1.30408 1.29208
21 2013.03.14 14:13 t/p 7 135.70 1.29208 1.30408 1.29208 9348.37 29704.73
22 2013.04.04 16:00 buy 8 198.03 1.27743 0.00000 0.00000
23 2013.04.04 16:00 modify 8 198.03 1.27743 1.27243 1.28443
24 2013.04.04 16:46 t/p 8 198.03 1.28443 1.27243 1.28443 13862.10 43566.83
25 2013.04.22 04:00 sell 9 290.44 1.30610 0.00000 0.00000
26 2013.04.22 04:00 modify 9 290.44 1.30610 1.31110 1.29910
27 2013.04.23 10:42 t/p 9 290.44 1.29910 1.31110 1.29910 20223.34 63790.17
28 2013.04.30 00:00 buy 10 425.26 1.31003 0.00000 0.00000
29 2013.04.30 00:00 modify 10 425.26 1.31003 1.30503 1.31703
30 2013.04.30 17:25 t/p 10 425.26 1.31703 1.30503 1.31703 29768.20 93558.37

yah kira-kira begitulah sodara-sodara

Salam

Okho

PHP Singleton Pattern

Posted: 5 Februari 2013 in Creative Zone

<?php

class TukangRoti{
private static $instance ;
private $roti;

public static function dipanggil( ) {
if( !self::$instance) {
self::$instance = new TukangRoti() ;
}

return self::$instance ;
}

public function __construct(){
$this->roti = 10;
}

public function beli(){
$this->roti–;
}

public function tinggal_berapa(){
return $this->roti;
}
}

$tr = TukangRoti::dipanggil();
echo ‘<br> Stok ‘.$tr->tinggal_berapa(); //10
echo ‘<br> Beli ‘.$tr->beli();
echo ‘<br> Stok ‘.$tr->tinggal_berapa(); //9
$tr2 = TukangRoti::dipanggil();
echo ‘<br> Joni Beli ‘.$tr2->beli();
echo ‘<br> Joni Stok ‘.$tr->tinggal_berapa(); //8
?>

Obat sedih

Posted: 28 September 2012 in Uncategorized

sedih/putus asa/ adalah tanggapan tubuh dari ketidaksesuaian menghadapi kondisi yang tidak sesuai kemauan

efeknya adalah melemahkan peredaran darah dan membangkitkan proses pertahanan tubuh seperti marah, menangis dan lain sebagainya

jika kondisi ini terjadi dengan terus menerus, mekanisme pertahanan tubuh akan menguras energi sehingga tubuh menjadi lemah

disinilah muncul penyakit yang sulit disembuhkan kecuali dengan obat penenang

solusi nya adalah melihat situasi tersebut dengan menggunakan cara pandang yang berbeda sehingga tubuh tidak perlu menguras energi berlebihan untuk berusaha menenangkan (menormalkan arus aliran darah)

perubahan cara pandang ini bisa menggunakan ajaran agama, kalimat motivasi, sugesti, dogma dan lain sebagainya
yang intinya adalah suatu pemahaman yang bisa merubah cara pandang terhadap suatu masalah

perubahan cara pandang ini berakibat juga perubahan kemauan yang pada akhirnya, hawa nafsu bisa dikendalikan

saya teringat ada ayat di alquran yang menyatakan bahwa dengan meningkatkan ilmu/pengetahuan, Allah pasti menaikkan derajat orang tersebut

simpanlah informasi yang bisa membuat kita kuat, bukan informasi yang membuat kita semakin lemah

rubahlah cara pandang Anda, rasakan hasilnya!

Allahu Akbar

CLIENT SIDE

#!/usr/bin/python

"""
TELNET OKHO
"""

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 50000))

def SendToServer(data):
        global sock
        sock.sendall(data)
        received = sock.recv(1024)
        return received

while 1:
        a = raw_input('cmd: ')
        if a == 'exit':
                sock.close()
                break
        data = SendToServer(a)
        print 'rec:', data
        print ''

MAN IN THE MIDDLE

#!/usr/bin/python

import SocketServer
import socket
from datetime import datetime, date, time
import logging

SERVER_ADDR = 'localhost'
SERVER_PORT = 50001
LOCAL_ADDR  = ''
LOCAL_PORT  = 50000
BUF_SIZE    = 1024
LOG_FILE    = '/home/okho/python/MITM.log'

logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG)

def hexdump(src, length=10):
    result = []
    digits = 4 if isinstance(src, unicode) else 2
    for i in xrange(0, len(src), length):
       s = src[i:i+length]
       hexa = b' '.join(["%0*X" % (digits, ord(x))  for x in s])
       text = b''.join([x if 0x20 <= ord(x) < 0x7F else b'.'  for x in s])
       result.append( b"%04X   %-*s   %s" % (i, length*(digits + 1), hexa, text) )
    return b'\n'.join(result)

def SendToServer(data):
        global sock
        sock.sendall(data)
        received = sock.recv(BUF_SIZE)
        return received

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((SERVER_ADDR, SERVER_PORT))

class TCPRequestHandler(SocketServer.BaseRequestHandler ):
    def setup(self):
        print self.client_address, 'connected!'
        #self.request.send('hi ' + str(self.client_address) + '\n')

    def handle_timeout(self):
        self.shutdown()

    def handle(self):
        global BUF_SIZE, LOG_FILE, server, logging
        data = 'dummy'
        while data:
            if data:
                data = self.request.recv(BUF_SIZE)
                log_data =  '[', str(datetime.now()), '] rec from client: ', str(self.client_address), "\n", hexdump(data)

                log_str =  ''.join(log_data)
                print log_str
                logging.info (log_str)

                realdata = SendToServer(data)

                log_data = '[',str(datetime.now()), '] rec from real server:\n',hexdump(realdata), '\n'
                log_str = ''.join(log_data)
                print log_str
                logging.info (log_str)
                self.request.send(realdata)
                print ''
                if data.strip() == 'mitm-bye':
                                server.shutdown()
                                return

    def finish(self):
        print self.client_address, 'disconnected!'
        #self.request.send('bye ' + str(self.client_address) + '\n')

server = SocketServer.ThreadingTCPServer((LOCAL_ADDR, LOCAL_PORT), TCPRequestHandler)
server.allow_reuse_address = True
#timeout 10 menit
server.timeout = 600
server.serve_forever()

REAL SERVER

#!/usr/bin/python
# a simple tcp server

import SocketServer

class TCPRequestHandler(SocketServer.BaseRequestHandler ):
    def setup(self):
        print self.client_address, 'connected!'
        #self.request.send('hi ' + str(self.client_address) + '\n')

    def handle(self):
                global server
                data = 'dummy'
                while data:
                        if data:
                                data = self.request.recv(1024)
                                print 'rec: ', data
                                self.request.send(data)
                                if data.strip() == 'bye':
                                        server.shutdown()
                                        return

    def finish(self):
        print self.client_address, 'disconnected!'
        #self.request.send('bye ' + str(self.client_address) + '\n')

#server host is a tuple ('host', port)
SocketServer.allow_reuse_address = True
server = SocketServer.ThreadingTCPServer(('', 50001), TCPRequestHandler)
server.serve_forever()

Harusnya memang awal puasa itu hari jumat 19 juli 2012 untuk indonesia.
Alasannya bisa dilihat di gambar dibawah

image

Bulan berada lebih dari 2 derajat

obat bingungnya hidup

Posted: 21 September 2011 in Uncategorized

KENAPA AKU DIUJI ?

QURAN MENJAWAB :
Qs. Al-Ankabut : 2-3 “Apakah manusia itu mengira bahwa mereka dibiarkan (saja) mengatakan: ‘Kami telah beriman’, sedang mereka tidak diuji lagi ? Dan sesungguhnya kami telah menguji orang-orang yang sebelum mereka, maka sesungguhnya Allah mengetahui orang-orang yang benar dan sesungguhnya Dia mengetahui orang-orang yang dusta.

KENAPA AKU TAK MENDAPAT APA YG AKU INGINKAN ?

QURAN MENJAWAB :
Qs. Al-Baqarah : 216 “Boleh jadi kamu membenci sesuatu padahal ia amat baik bagimu dan boleh jadi pula kamu menyukai sesuatu padahal ia amat buruk bagimu, Allah mengetahui sedang kamu tidak mengetahui

KENAPA UJIAN SEBERAT INI ?

QURAN MENJAWAB :
Qs. Al-Baqarah : 286 “Allah tidak membebani seseorang itu melainkan sesuai dengan kesanggupannya.

KENAPA FRUSTASI ?

QURAN MENJAWAB :
Qs. Al-Imran : 139 “Janganlah kamu bersikap lemah, dan janganlah pula kamu bersedih hati, padahal kamulah orang2 yg paling tinggi derajatnya, jika kamu orang2 yg beriman

BAGAIMANA AKU HARUS MENGHADAPINYA ?

QURAN MENJAWAB :
Qs. Al-Baqarah : 45 “Dan mintalah pertolongan (kepada Allah) dengan jalan sabar dan mengerjakan sholat; dan sesungguhnya sholat itu amatlah berat kecuali kepada orang-orang yang khusyuk” Tiada daya dan upaya kecuali atas pertolongan Allah semata.

APA YANG AKU DAPAT ?

QURAN MENJAWAB :
Qs. At-Taubah : 111 “Sesungguhnya Allah telah membeli dari orang2 mu’min, diri, harta mereka dengan memberikan jannah utk mereka”

KEPADA SIAPA AKU BERHARAP ?

QURAN MENJAWAB :
Qs. At-Taubah : 129 “Cukuplah Allah bagiku, tidak ada Tuhan selain dari-Nya. Hanya kepada-Nya aku bertawakkal.

AKU TAK SANGGUP !!

QURAN MENJAWAB :
Qs. Yusuf : 87 “Dan janganlah kamu berputus asa dari rahmat Allah. Sesungguhnya tiada berputus asa dari rahmat Allah melainkan kaum yg kafir…

Semoga bermanfaat,