Coding untuk BUY @ SELL

Live Forex Chart

Currency
Rates
EUR / USD
1.18089
USD / JPY
104.608
GBP / USD
1.30239
USD / CHF
0.90918
USD / CAD
1.31933
EUR / JPY
123.530
AUD / USD
0.71245

CG Sponsors




sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
Assalamualaikum dan salam sejatera.

Tujuan aku buka threat ni untuk berkongsi coding untuk BUY dan SELL mengikut indicator-indicator sebagaimana yang ada di dalam EA.Jadi diminta kaki-kaki cantas jangan ganggu dan nak mencantas aku sebagaimana yang lepas.Ini untuk belajar dan berkongsi.Berguna untuk sesiapa yang ingin belajar membuat EA sendiri dengan indicator pilihan anda sendiri.

int Current;

//======================BUY=======================

//Moving Average
double Buy1_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 1);
double Buy1_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);
double Buy2_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

//SAR
double Buy3_1 = iSAR(NULL, 0, 0.005, 0.05, Current + 1);
double Buy3_2 = iSAR(NULL, 0, 0.005, 0.05, Current + 0);

//MACD
double Buy4_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 1);
double Buy4_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 0);

//==================SELL===========================

double Sell1_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 1);
double Sell1_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1); double Sell2_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell3_1 = iSAR(NULL, 0, 0.005, 0.05, Current + 1);
double Sell3_2 = iSAR(NULL, 0, 0.005, 0.05, Current + 0);

double Sell4_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 1);
double Sell4_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 0);

//=============================================

if (Buy1_1 < Buy1_2 && Buy2_1 >= Buy2_2 && Buy3_1 < Buy3_2 && Buy4_1 < Buy4_2) Order = SIGNAL_BUY;

if (Sell1_1 > Sell1_2 && Sell2_1 <= Sell2_2 && Sell3_1 > Sell3_2 && Sell4_1 > Sell4_2) Order = SIGNAL_SELL;

Contoh-contoh lain : -

if (iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,0) > iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) Cmd = 2; //BUY
if (iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,0) < iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) Cmd = 1; //SELL
 
Sponsored Post

sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
if (iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE _MAIN,0) > iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) Cmd = 2; //BUY
if (iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE _MAIN,0) < iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) Cmd = 1; //SELL
Boleh ditukar dengan susunan begini bergantung pada kefahaman masing-masing.

double MACD1 = iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,0);
double MACD2 = iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,1);

if ( MACD1 > MACD2 ) Cmd = 2; //BUY

double MACD3 = iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,0);
double MACD4 = iMACD(NULL,MACDTimeFrame,14,26,9,PRICE_CLOSE,MODE_MAIN,1);

if ( MACD3 < MACD4 ) Cmd = 1; //SELL
 

anoone

Legendary Member
Joined
Mar 26, 2008
Messages
12,410
Reaction score
60
Points
120
cayok2 bro sunny.......boleh dijadikan panduan....
 

sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
Untuk external atau iCustom indicator, berikut adalah coding menggunakan indicator Bogie-NN-IND-v8.

extern double BuyTrigger = 54;
extern double SellTrigger = 74;

ind1 = iCustom(NULL,PERIOD_H1,"Bogie-NN-IND-v8",1,1);
ind2 = iCustom(NULL,PERIOD_H1,"Bogie-NN-IND-v8",1,2);

if ((ind2 <= BuyTrigger) && (ind1 >= BuyTrigger)) signal = "BUY"; else signal = "NONE";
if ((ind2 >= SellTrigger) && (ind1 <= SellTrigger)) signal = "SELL"; else signal = "NONE";
untuk TimeFrame, boleh ditukar pada TF yang anda ingin gunakan.Contoh yang ada sekarang untuk TF daily.Jadi kalau anda ingin menukarkan
TF30 contohnya ... Jadikan begini...

ind1 = iCustom(NULL,PERIOD_M30,"Bogie-NN-IND-v8",1,1);
 
Last edited:

miXxer

Legendary Member
Joined
Nov 12, 2007
Messages
13,252
Reaction score
63
Points
120
pening aku bab coding neh.. #:-S
 

anoone

Legendary Member
Joined
Mar 26, 2008
Messages
12,410
Reaction score
60
Points
120
tanya jer..masta coding dh ada nih....
 

sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
pening aku bab coding neh.. #:-S
Sebab tu aku ada kasi tau...untuk yang nak belajar buat ea...kene belajar MODIFIED.Kalau terus nak tulis ea sendiri tanpa sebarang panduan memang takkan jadi.Tu pendapat aku yang hanya belajar sampai Tingkatan 4 je.Kalau ada yang sampai U sila la tunjuk ajar aku pulak yerk.
 

sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
nak start katne pon x reti hehehe..

hang dok mane sunny? kalo ada kl leh gk lepak ngeteh..
Skang ni aku kat Cheras.Kebetulan aku kat KL sampai 23hb.Nak minum-minum takde hal.
 

sunnyfx

Super Active Member
Joined
Jan 6, 2008
Messages
7,802
Reaction score
73
Points
70
Sekiranya, mahukan indicator tersebut comform signal ( filter ) pada 4 TF. Aku andaikan TF5,TF15,TF30,TFH1.Ibarat pasang indicator pada 4 TF.Bila ngam dan sama signal diperolehi dari kesemua TF tersebut, arahan BUY atau SELL baru berjalan.Buatkan begini : =

extern double BuyTrigger = 54;
extern double SellTrigger = 74;

ind_5 = iCustom(NULL,PERIOD_M5,"Bogie-NN-IND-v8",1,1);
ind_5m = iCustom(NULL,PERIOD_M5,"Bogie-NN-IND-v8",1,2);

ind_15 = iCustom(NULL,PERIOD_M15,"Bogie-NN-IND-v8",1,1);
ind_15m = iCustom(NULL,PERIOD_M15,"Bogie-NN-IND-v8",1,2);

ind_30 = iCustom(NULL,PERIOD_M30,"Bogie-NN-IND-v8",1,1);
ind_30m = iCustom(NULL,PERIOD_M30,"Bogie-NN-IND-v8",1,2);

ind_H1 = iCustom(NULL,PERIOD_H1,"Bogie-NN-IND-v8",1,1);
ind_H1m = iCustom(NULL, PERIOD_H1,"Bogie-NN-IND-v8",1,2);

if (( ind_5m <= BuyTrigger) && (ind_5 >= BuyTrigger ) &&
( ind_15m <= BuyTrigger) && (ind_15 >= BuyTrigger ) &&
( ind_30m <= BuyTrigger) && (ind_30 >= BuyTrigger ) &&
( ind_H1m <= BuyTrigger) && (ind_H1 >= BuyTrigger ))
signal = "BUY"; else signal = "NONE";

//========================================

if (( ind_5m >= SellTrigger) && (ind_5 <= SellTrigger ) &&
( ind_15m >= SellTrigger) && (ind_15 <= SellTrigger ) &&
( ind_30m >= SellTrigger) && (ind_30 <= SellTrigger ) &&
( ind_H1m >= SellTrigger) && (ind_H1 <= SellTrigger ))
signal = "SELL"; else signal = "NONE";
 
Sponsored Post
Top
Log in Register