非常にシンプルなEAを作成するためのヘルプが必要 - ページ 3

 

//+------------------------------------------------------------------+
//| Stepper.mq4 |
//| doshur |
//| www.doshur.com |
//+------------------------------------------------------------------+
#property copyright "doshur"
#property link "www.doshur.com"

extern int TakeProfit = 5;
extern int Range = 20;
extern int Risk = 2;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}

int deinit()
{
return(0);
}

int start()
{
//----
static bool ToTrade = false;
static bool FirstTrade = true;

double PrevLow = iLow(Symbol(), 0, 1);
double PrevHigh = iHigh(Symbol(), 0, 1);
double PrevRange = (PrevHigh - PrevLow) / Point;

if(NewBar())
{
if(FirstTrade == false)
{
if(PrevRange >= Range)
ToTrade = true;
else
ToTrade = false;
}
else
{
FirstTrade = false;
}
}

if(ToTrade)
{
if(COT(1) < 1)
{
if(Ask > PrevHigh)
OrderSend(Symbol(), OP_BUY, MM(PrevRange, Risk), Ask, 3, PrevLow, Ask + TakeProfit * Point, "Stepper - BUY", 57390, 0, Blue);
}

if(COT(2) < 1)
{
if(Bid < PrevLow)
OrderSend(Symbol(), OP_SELL, MM(PrevRange, Risk), Bid, 3, PrevHigh, Bid - TakeProfit * Point, "Stepper - SELL", 57391, 0, Red);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+

//---- Check Is New Bar
bool NewBar()
{
static datetime PrevBar;

if(PrevBar < Time[0])
{
PrevBar = Time[0];
return(true);
}
else
{
return(false);
}

return(false);
}

//---- Check Open Trades
int COT(int BS)
{
int Buys = 0, Sells = 0;

for(int cnt_COT = 0; cnt_COT < OrdersTotal(); cnt_COT++)
{
OrderSelect(cnt_COT, SELECT_BY_POS, MODE_TRADES);

if(OrderType() == OP_BUY && OrderSymbol() == Symbol()) Buys++;
if(OrderType() == OP_SELL && OrderSymbol() == Symbol()) Sells++;
}

if(BS == 1) return(Buys);
if(BS == 2) return(Sells);
}

//---- Money Management
double MM(int SL, int RK)
{
double rLots = NormalizeDouble(AccountBalance() / 1000 * RK / SL, 1); // Risk ?% of balance

if(rLots < 0.1) rLots = 0.1;

return(rLots);
}


この問題を克服するための最初の実行と、その他のいくつかの問題を実装していました。

コードのテストはしていない

テストして、他の修正点をリストアップしてください。

 

is there away where we can modify the stop loss to so 15 or 20 instead of the other end of the candle?

 

crazfoto 2008.12.02 08:27我々はそう15または20の代わりにろうそくの他の端にストップロスを修正することができます離れてそこにあるのでしょうか?


はい。それは可能です。

 

これは2時間平均のものでしょうか、それとも30分の別バージョンでしょうか?


もし2時間平均なら、昨日は何の取引も実行されませんでした。

 
crazfoto:

これは2時間平均のものですか? それとも30分の別バージョンですか?


もし2時間平均なら、昨日は何の取引も実行されませんでした。

私のコードのことですか?

ご要望の通り、30分間実装しました。

 

ああ、悪かった。今テストしてみるよ。


4時間足チャートで遊んでみました。4時間足チャートでストップを15か20pipsに変更すれば、結果は良くなると思います。

 
オフラインの2時間チャートで動作しますか?オフラインのチャートでEAを使うのに問題がある人がたくさんいるのを見ます。
 
1時間足チャートのみで動作します
 
30分足チャートで動作していますが、1つの注文が決済されるたびに注文を入れ続けています。
 

おっと。

一度入力したら無効化するのを忘れていました。

コードを修正します。