ผมลองเขียน จากที่ admin ให้ตัวอย่างมา ปรากฎว่าไม่ทำงาน เลยจะขอให้ช่วยดูข้อผิดพลาดครับ
code
double lots = 0.1;
double pclose0 = iClose(NULL,0,0);
double pclose1 = iClose(NULL,0,1);
double pclose2 = iClose(NULL,0,2);
double pclose3 = iClose(NULL,0,3);
double mclose0 = iMA(NULL,0,20,0,MODE_SMMA,PRICE_WEIGHTED,0);
double mclose1 = iMA(NULL,0,20,0,MODE_SMMA,PRICE_WEIGHTED,1);
double mclose2 = iMA(NULL,0,20,0,MODE_SMMA,PRICE_WEIGHTED,2);
double mclose3 = iMA(NULL,0,20,0,MODE_SMMA,PRICE_WEIGHTED,3);
double takeprofit;
double stoploss;
double zz0 , zz1 , zz2 , zz3 , zz4 , zz5 , zz6 ;
double rsi0 , rsi1 , rsi2 , rsi3 , rsi4 , rsi5 , rsi6 ;
double ma0 , ma1 , ma2 , ma3 , ma4 , ma5 , ma6 ;
{
int amount=0;
double tem;
double rsi;
double ma;
double temp[7];
double rtemp[7];
double mtemp[7];
for(int i=0 ;i<5000;i++)
{
tem = iCustom(NULL, 0, "ZigZag",7,5,7,0,i);
rsi = iRSI(NULL,0,14,PRICE_WEIGHTED,i);
ma = iMA(NULL,0,20,0,MODE_SMMA,PRICE_WEIGHTED,i);
if(tem>0)
{
temp[amount]=tem;
rtemp[amount]=rsi;
mtemp[amount]=ma;
amount++;
if(amount>7)
{
i=5001;
}
zz0 = temp[0];
zz1 = temp[1];
zz2 = temp[2];
zz3 = temp[3];
zz4 = temp[4];
zz5 = temp[5];
zz6 = temp[6];
rsi0 = rtemp[0];
rsi1 = rtemp[1];
rsi2 = rtemp[2];
rsi3 = rtemp[3];
rsi4 = rtemp[4];
rsi5 = rtemp[5];
rsi6 = rtemp[6];
ma0 = mtemp[0];
ma1 = mtemp[1];
ma2 = mtemp[2];
ma3 = mtemp[3];
ma4 = mtemp[4];
ma5 = mtemp[5];
ma6 = mtemp[6];
}
}
if (zz0 > zz1)
{
if (((zz0 - zz2) > (15*Point)) && ((zz2 - zz3) > (35*Point)) && (rsi1 > 35) && (rsi2 >= 70) && (zz2 > ma2) && ((pclose0 - mclose0) < (10 * Point)) && (pclose1 > mclose1))/// && (pclose2 > mclose2) && (pclose3 > mclose3)
{
takeprofit = ((zz2 + (zz2 - zz3)) - (5 * Point));
stoploss = zz1;
OrderSend(Symbol(),OP_BUY,lots,Ask,3,stoploss,takeprofit,"buy",0,0,Green);
}
}
if (zz0 < zz1)
{
if (((zz2 - zz0) > (15*Point)) && ((zz3 - zz2) > (35*Point)) && (rsi1 < 65) && (rsi2 <= 30) && (zz2 < ma2) && ((mclose0 - pclose0) < (10 * Point)) && (pclose1 < mclose1)) /// && (pclose2 < mclose2) && (pclose3 < mclose3)
{
takeprofit = ((zz2 - (zz3 - zz2)) + (5 * Point));
stoploss = zz1;
OrderSend(Symbol(),OP_SELL,lots,Bid,3,stoploss,takeprofit,"sell",0,0,Red);
}
}