RSIを使用した順張りでサインを出す

この記事には広告・プロモーションが含まれています

自力でサインツールを作成してみたんですが、どうも上手くできません!
RSIを使用した順張りでサインを出したいのですが出来ません。

RSIが60超えたら上サイン、40を下抜けたら下サイン
サイン出現時にアラートも出したいんですが出来ませんでした。
よろしくおねがいします!

自作のスクリプトは以下の通りです↓

#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_color1 clrAntiqueWhite
#property indicator_color2 clrAntiqueWhite
#property indicator_width1 2
#property indicator_width2 2

double arrEntUp[],arrEntDown[];
int maxlimit = 1000;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorBuffers(2);
SetIndexBuffer(0,arrEntUp);
SetIndexBuffer(1,arrEntDown);

SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID);

SetIndexArrow(0,241);
SetIndexArrow(1,242);

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--

double dRsiNow,dRsiBak;
for(int i=maxlimit; i>1; i--){
dRsiNow = iRSI(NULL,0,14,PRICE_CLOSE,i);
dRsiBak = iRSI(NULL,0,14,PRICE_CLOSE,i+1);

arrEntUp[i] = EMPTY_VALUE;
arrEntDown[i] = EMPTY_VALUE;

if(dRsiBak >=40 && dRsiNow <40){ arrEntDown[i]=Low[i]; }else if(dRsiBak <=60 && dRsiNow <60){ arrEntUp[i]=High[i]; } } //--- return value of prev_calculated for next call return(rates_total); } //+-----------------------------------------------------------------+

アンケートに回答してくださりまして、誠にありがとうございます。

表示がおかしいのは、dRsiNow <60 を dRsiNow >60 に変えるだけです。

アラートも付けてファイルをアップしましたので、ダウンロードして参考にしてみてください。

ダウンロードはこちら(2023/03/22)

これからもよろしくお願いいたします。

コメント

  1. 高本 より:

    1 Windows
    2   MT4
    3 BIG BOSS USDJPYなど ローソク足、サインツール

    初めまして。
    お世話になります。
    今使っているサインツールで自動売買にしたいのですが、
    RSIが70を超えたらサインが出ない、30を下回ったらサインが出ないというのは可能でしょうか?

    • masa masa より:

      高本様
      コメントありがとうございます。
      コードに条件を加えると可能のはずですが、サインツールがどのようなものかにもよると思います。
      これからもよろしくお願いいたします。

  2. 高本 より:

    masa様
    お返事ありがとうございます。
    サインツールを見ていただきたいのですが
    添付の仕方がわからないのです。
    お手数おかけします

    • masa masa より:

      高本様
      私が勘違いしてました。
      大変申し訳ございませんが、個別のコード対応につきましては承っておりません。
      何卒ご理解いただけますと幸いです。