このページでは、エントリー時間の価格と判定時間の価格を比較して、そのエントリーが勝っているのか負けているのかを判断し、勝敗をprintf()で表示できるようにしてみます。
前回からの続きのコードを使用しますので、読んでない方は先にこちらをご覧ください。

全体の流れのおさらい
全体の流れは以下の通りでした。
- エントリー時間と判定時間を求める
- エントリー中は別のエントリーを行わない
- 判定時刻を迎えたらエントリーと判定時の価格を比較する
- 比較結果から勝敗を決める
- 勝敗結果を出力する
このページでは⑤について解説していきます。
勝敗数をカウントする
勝敗数をカウントする方法をどのようにしていけば良いかですが、int型のグローバル変数をそれぞれ用意して、勝った場合の変数に「1」足して、負けた場合の変数に「1」足してというように書いていけば良いです。
まずはグローバル変数を用意します。

Lowエントリー用の勝ちと負けの変数、Highエントリー用の勝ちと負けの変数4つを宣言します。
あとは1ずつ足していくだけなので、コードは以下のようになります。

if(Entry_Value - Judge_Value > 0) { //Win LowWins++; } else { //Lose LowLoses++; }
「++」は「1を足す」と同じ意味になりますので、このように書くことでカウントされていきます。
フラグを元に戻す
エントリーをした際に「EntryFlag」を「true」にしましたので、判定が終わったら「false」に戻さなければなりません。
「false」に戻すコードは以下の部分に追加します。

勝敗結果を出力する
printf()関数を使って勝敗結果を確認してみましょう。
知りたい値は、勝ち数/負け数をカウントするために用意したグローバル変数の中身です。
printf()関数を使って以下のように追加します。

printf("LowWins: %d LowLoses: %d HighWins: %d HighLoses: %d",LowWins,LowLoses,HighWins,HighLoses);
printf()関数の説明については省略しますが、このようにコードを書くことで、MT4上の「エキスパート」タブで確認することが出来るようになります。
実際にMT4上で確認してみましょう。デバッグのスタートボタンを押してください。


しっかりと値が1ずつ増えて表示されているのがわかります。同じ通貨でもローソク足の本数や機関の違いで結果は異なりますのでご注意ください。
このロジックだと勝てていないということが分かります。
ここまでできれば十分バックテストが出来る実力は身についています。
もっと細かい条件や制御などを行おうとすると、さらにコードを改善したり工夫していかなければなりませんが、少しずつ自分なりの改良を行っていくと自然と実力も上がっていきます。

コメント
コメント一覧 (33件)
gmog3b
https://pinupaz.top/# pin-up
https://t.me/s/flagman_official_777/109
generic tadalafil: discreet shipping ED pills – buy generic Cialis online
https://t.me/s/flagman_official_777/169
https://t.me/s/flagman_official_777/87
secure checkout ED drugs: FDA approved generic Cialis – discreet shipping ED pills
order Viagra discreetly: fast Viagra delivery – Viagra without prescription
buy generic Cialis online: secure checkout ED drugs – buy generic Cialis online
fast Viagra delivery: legit Viagra online – discreet shipping
safe online pharmacy: generic sildenafil 100mg – cheap Viagra online
verified Modafinil vendors: buy modafinil online – modafinil legality
safe online pharmacy: safe online pharmacy – trusted Viagra suppliers
modafinil pharmacy: modafinil legality – modafinil pharmacy
affordable ED medication: order Cialis online no prescription – buy generic Cialis online
doctor-reviewed advice: verified Modafinil vendors – verified Modafinil vendors
no doctor visit required: order Viagra discreetly – buy generic Viagra online
order Cialis online no prescription: affordable ED medication – online Cialis pharmacy
PredniHealth: prednisone over the counter uk – PredniHealth
PredniHealth: generic prednisone cost – PredniHealth
can i buy clomid online: can i purchase generic clomid online – can you get generic clomid prices
Amo Health Care: over the counter amoxicillin – order amoxicillin online uk
prednisone 10 mg over the counter: PredniHealth – prednisone 50 mg canada
order amoxil – comba moxi amoxicillin sale
order fluconazole 100mg generic – this diflucan usa
purchase lexapro for sale – https://escitapro.com/# buy generic escitalopram 20mg
oral cenforce – https://cenforcers.com/ cenforce 100mg brand
cialis leg pain – https://ciltadgn.com/ how much does cialis cost at walmart
tadalafil medication – https://strongtadafl.com/# natural cialis
order ranitidine 300mg online – https://aranitidine.com/# order zantac sale
viagra soft tabs cheap – https://strongvpls.com/ 100mg sildenafil price
This is a keynote which is near to my verve… Myriad thanks! Faithfully where can I find the phone details due to the fact that questions? buy gabapentin 100mg generic
Greetings! Very gainful suggestion within this article! It’s the scarcely changes which will make the largest changes. Thanks a quantity in the direction of sharing! cenforce 100 opiniones