Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Piano - script for MetaTrader 5

Views:
633
Rating:
(3)
Published:
2025.04.27 08:10
Sounds.zip (948.92 KB)
Piano.mq5 (2.5 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Listen to the rhythm of your candlesticks

This script plays Piano keys A B C and D wav files based on candlestick properties. Higher green plays higher notes while falling bears plays lower note

Sounds wav files should be placed inside Files/Sounds Folder

Copy this code and paste a new script. If you download the file"uncomment the lines" where its written and compile

//+------------------------------------------------------------------+
//|                                                        Piano.mq5 |
//|                                Copyright 2025, Rajesh Kumar Nait |
//|                  https://www.mql5.com/en/users/rajeshnait/seller |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Rajesh Kumar Nait"
#property link      "https://www.mql5.com/en/users/rajeshnait/seller"
#property version   "1.00"

#property strict
#property script_show_inputs

// Inputs you can set
input int BarsToPlay = 20;       // How many bars to play music
input double NoteDelay = 0.5;     // Seconds between notes (tempo)

#resource "\\Files\\Sounds\\A.wav"
#resource "\\Files\\Sounds\\B.wav"
#resource "\\Files\\Sounds\\C.wav"
#resource "\\Files\\Sounds\\D.wav"

// Notes array (only 4 notes: A, B, C, D)
string notes[] = {"A", "B", "C", "D"};

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart() {
//---
   int note_index = 0;  // Starting note
   int total_bars = BarsToPlay;

   if (total_bars <= 0) {
      Print("Invalid BarsToPlay. It must be > 0.");
      return;
   }

   datetime last_bar_time = iTime(NULL, PERIOD_CURRENT, 0);

   // Go from (BarsToPlay) bars ago up to bar 1 (newest closed candle)
   for (int i = total_bars; i >= 1; i--) {
      // Get candle data
      double open  = iOpen(NULL, PERIOD_CURRENT, i);
      double close = iClose(NULL, PERIOD_CURRENT, i);

      // Determine candle color
      bool isGreen = close > open;
      bool isRed   = close < open;

      // Move note index
      if (isGreen)
         note_index++;
      else if (isRed)
         note_index--;

      // Clamp note_index between 0 and ArraySize(notes) - 1
      if (note_index < 0)
         note_index = 0;
      if (note_index >= ArraySize(notes))
         note_index = ArraySize(notes) - 1;

      // Play the sound
      string play_note = notes[note_index];
      PlaySound("::Files\\Sounds\\"+play_note + ".wav");

      // Wait for the next note
      Sleep((int)(NoteDelay * 1000)); // Convert seconds to milliseconds
   }

   Print("Music finished playing ", total_bars, " bars!");
}
//+------------------------------------------------------------------+


CTJM Candle Timer - Indicator for MT5 CTJM Candle Timer - Indicator for MT5

This indicator will shows the time remaining until the end of the candle. You can choose colour and the font size.

Volume MA with candle color tracking Volume MA with candle color tracking

A moving average of pure tick volume with histogram bars tracking bullish/bearish candle color

Custom MA Cross with RSI Indicator for MT5 Custom MA Cross with RSI Indicator for MT5

The Custom MA Cross with RSI Indicator for MT5 is a versatile trading tool designed to help traders identify trend changes and filter entries using momentum. This indicator combines two moving averages (MA) with the Relative Strength Index (RSI), offering clear buy and sell signals.

SignalAI - Indicator SignalAI - Indicator

This Indicator shows Buy or Sell Signal