Author: Müller Peter
Price Data Components
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
Signaltest
ÿþ//+------------------------------------------------------------------+

//|                                                      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>



input int TP_Points = 50;

input int SL_Points = 400;

input double BaseLotSize = 0.01;

input int MomentumPeriod = 14;

input int MomBuyLevel = 110;

input int MomSellLevel = 90;

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)));

   Print(DoubleToStr(PointsGained) + " Points gained, Consecutive losses: "+ DoubleToStr(ConsecLosses));

   

   return(INIT_SUCCEEDED);

}



void OnTick()

{

   if(!IsNewCandle())   

      return;

   

   double TP,SL;

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

   {

      int cmd;

      double Price;

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

      {

         cmd = OP_BUY;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

      }

      else 

      {

         cmd = OP_SELL;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_BID);

      }

      if(OrderSend(_Symbol,cmd,BaseLotSize,Price,50,SL,TP) == -1)

         PrintFormat("Could not open order Error code: %d",GetLastError());

   }

}







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 ---