Skip to content

Instantly share code, notes, and snippets.

View jimtin's full-sized avatar

James Hinton jimtin

View GitHub Profile
@jimtin
jimtin / doji_star.mq5
Created July 16, 2024 22:25
Doji Star Pattern in MQL5
//+------------------------------------------------------------------+
//| Expert Doji Star Pattern |
//+------------------------------------------------------------------+
bool DojiStar(double open, double close, double high, double low)
{
// Calculate the body size
double bodySize = MathAbs(close - open);
// Print all the values for debugging
//Print("Body Size: ", bodySize, " Open: ", open, " Close: ", close, " High: ", high, " Low: ", low, " Time: ", TimeToString(TimeCurrent()));
bool isBodySmall = false;
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 7, 2024 21:37
Full code for episode
//+------------------------------------------------------------------+
//| RSI_EA_from_TradeOxy.mq5 |
//| AppnologyJames, TradeOxy.com |
//| https://www.tradeoxy.com |
//+------------------------------------------------------------------+
// CTrade Class
#include <Trade\Trade.mqh>
input bool liveRSIPrice = false; // Use live RSI price?
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 7, 2024 21:18
Making TradeManagement function more dynamic
//+------------------------------------------------------------------+
//| TradeManagement Function |
//+------------------------------------------------------------------+
bool TradeManagement(){
// Get the total number of orders
int totalOrders = OrdersTotal();
// Get the total number of positions
int totalPositions = PositionsTotal();
// If there are no orders or positions, return true
if(totalOrders == 0 && totalPositions == 0){
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 7, 2024 08:54
OnTick() Update to Include TradeManagement()
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
bool tradeManagement = TradeManagement();
if(tradeManagement == true){
double rsi = GetRSI();
string signal = RSIAlgorithm(rsi);
bool success = OnSignal(signal);
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 7, 2024 08:50
TradeManagement() Function
//+------------------------------------------------------------------+
//| TradeManagement Function |
//+------------------------------------------------------------------+
bool TradeManagement(){
// Get the total number of orders
int totalOrders = OrdersTotal();
// Get the total number of positions
int totalPositions = PositionsTotal();
// If there are no orders or positions, return true
if(totalOrders == 0 && totalPositions == 0){
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 6, 2024 20:08
Full code for episode: The Easiest Way to Execute BUY and SELL Orders with your MetaTrader EA
//+------------------------------------------------------------------+
//| RSI_EA_from_TradeOxy.mq5 |
//| AppnologyJames, TradeOxy.com |
//| https://www.tradeoxy.com |
//+------------------------------------------------------------------+
// CTrade Class
#include <Trade\Trade.mqh>
input bool liveRSIPrice = false; // Use live RSI price?
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 6, 2024 19:57
Making the Code DRY
//+------------------------------------------------------------------+
// OnSignal Function |
//+------------------------------------------------------------------+
bool OnSignal(string signal){
// Get the current ask price
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
// Get the pip size for the current symbol
double pointSize = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
// Multiply the point size by 10 to get pips
double pipSize = pointSize * 10;
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Created June 6, 2024 19:46
Updated OnSignal function
//+------------------------------------------------------------------+
// OnSignal Function |
//+------------------------------------------------------------------+
bool OnSignal(string signal){
// Get the current ask price
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
// Get the pip size for the current symbol
double pointSize = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
// Multiply the point size by 10 to get pips
double pipSize = pointSize * 10;
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Last active June 4, 2024 20:11
Updated OnTick() function
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double rsi = GetRSI();
string signal = RSIAlgorithm(rsi);
if(signal == "BUY"){
Print("BUY Signal Detected");
bool result = OnSignal(signal);
@jimtin
jimtin / rsi_trading_bot_tutorial.mq5
Last active June 6, 2024 19:43
Updated OnSignal Function
//+------------------------------------------------------------------+
// OnSignal Function |
//+------------------------------------------------------------------+
bool OnSignal(string signal){
// Get the current ask price
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
// Get the pip size for the current symbol
double pointSize = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
// Multiply the point size by 10 to get pips
double pipSize = pointSize * 10;