SignalsTest

Author: Müller Peter
Price Data Components
0 Views
0 Downloads
0 Favorites
SignalsTest
ÿþ//+------------------------------------------------------------------+

//|                                                      Scanner.mq4 |

//|                        Copyright 2021, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Müller Peter"

#property link      "https://www.mql5.com/en/users/mullerp04/seller"

#property version   "1.00"

#property strict

#include <SignalClass.mqh>

#include  <Trade\Trade.mqh>



input int TP_Points = 150;

input int SL_Points = 150;

input double BaseLotSize = 0.01;

input int MomentumPeriod = 14;

input int MomBuyLevel = 100;

input int MomSellLevel = 100;

input int Slow_Movingaverage = 55;

input int Fast_Movingaverage = 10;

input int MACD_SlowPeriod = 26;

input int MACD_FastPeriod = 12;

input int MACD_SignalPeriod = 9;

input int BollingerPeriod = 20;

input int BollingerDeviation = 2;

input int RSIPeriod = 14;

input int RSIBuyLevel = 30;

input int RSISellLevel = 70;

input bool TradeWithTrend = false;







MomentumSignal MomSig(_Symbol,PERIOD_CURRENT,MomentumPeriod,TP_Points*Point(),SL_Points*Point(),MomBuyLevel,MomSellLevel);

MACrossover MASignal(_Symbol,PERIOD_CURRENT,Slow_Movingaverage,Fast_Movingaverage,MODE_SMA,TP_Points*Point(),SL_Points*Point());

RSISignal RsiSig(_Symbol,PERIOD_CURRENT,RSIPeriod,RSIBuyLevel,RSISellLevel,TP_Points*Point(),SL_Points*Point());

MACDSignal MACDSig(_Symbol,PERIOD_CURRENT,MACD_FastPeriod,MACD_SlowPeriod,MACD_SignalPeriod,TP_Points*Point(),SL_Points*Point());

BollingerSignal BBSig(_Symbol,PERIOD_CURRENT,BollingerPeriod,BollingerDeviation,TP_Points*Point(),SL_Points*Point());



int OnInit()

{   

   if(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP) == 0.001) 

      Decimal = 3;

   if(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP) == 1)

      Decimal = 0;

   double PointsGained;

   int ConsecLosses;

   Print("signal entry success rate: "+ DoubleToStr(MACDSig.WinRate(1000,PointsGained,ConsecLosses)));

   return(INIT_SUCCEEDED);

}



void OnTick()

{

   if(!IsNewCandle())   

      return;

   CTrade Trade;

   if(!MarketOpen())

      return;

   double TP,SL;

   if(MASignal.Entry(0,TP,SL)) // Entry at current (0).th bar? if so what is the tp and sl

   {  

      Trade.SetDeviationInPoints(50);  // Set the deviaton of the trade execution

      Trade.SetExpertMagicNumber(1000);    // Set the magic number of the trade

      int cmd;

      double Price;

      if(TP > SL)    // if tp  > sl  this has to be a buy trade

      {

         cmd = 1;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

      }

      else 

      {

         cmd = 0;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_BID);

      }

      TP = Round(TP,Digits());

      SL = Round(SL,Digits());

      if(!cmd)

      {

         if(!Trade.Sell(BaseLotSize,_Symbol,Price,SL,TP))

            PrintFormat("SELL ORDER could not be executed  error code: %d , Stoploss :%lf ,enterprice: %lf , TP : %lf" ,GetLastError(),SL,Price,TP);

      }

      if(cmd)

      {

         if(!Trade.Buy(BaseLotSize,_Symbol,Price,SL,TP))

            PrintFormat("BUY ORDER could not be executed  error code: %d , Stoploss :%lf, enterprice: %lf  , TP : %lf",GetLastError(),SL,Price,TP);

      }

   }

}







Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---