SVM_train_v02

Download script
Author: Copyright � 2007, MetaQuotes Software Corp.
SVM_train_v02

This script functions as an intelligent technical analysis tool designed to project potential market movements by leveraging historical data and a sophisticated learning process. Unlike standard indicators that rely solely on static mathematical formulas (like moving averages), this tool uses a "training" methodology to interpret price action.

Core Methodology: The Learning Process

The primary logic of the script is built around an automated training phase. When the indicator is first loaded, it scans a significant volume of historical market data—specifically looking at 4,000 past data points across a designated timeframe (such as 5-minute charts).

During this phase, the script examines the relationship between:

  • Price Points: The specific opening, closing, highs, and lows of previous candles.
  • Risk Parameters: It incorporates user-defined "Stop Loss" and "Take Profit" targets to understand the boundaries of successful trades in the past.

By feeding this data into a specialized external processing engine, the script attempts to identify patterns that historically led to successful outcomes while staying within the desired profit and risk limits.

Data Mapping and Execution

Once the training is complete, the script creates a "result map." This map stores the findings from the historical analysis so they can be projected onto your current trading chart. The logic follows these steps:

  1. Data Synchronization: Because the script may train on a different timeframe than what you are currently viewing (e.g., training on 5-minute data but viewing it on a 1-hour chart), it includes a synchronization layer. This ensures that the historical predictions align perfectly with the correct time slots on your screen.
  2. Visual Representation: The results of this analysis are displayed as a histogram. Instead of just showing where the price was, the tool aims to provide a visual representation of the "training result"—essentially highlighting areas where the logic identifies specific market characteristics based on its historical learning.

Key User Features

  • Customizable Timeframes: You can define which timeframe the "learning" should occur on, allowing you to capture different market dynamics (short-term scalping vs. long-term trends).
  • Dynamic Risk Boundaries: By adjusting the Stop Loss and Take Profit settings in the configuration, you can change how the script filters its historical results, essentially telling the logic what kind of "winning" trades it should prioritize during its training phase.

In summary, this tool acts as a predictive overlay. It studies the past 4,000 candles to learn the "DNA" of successful price movements and then plots those findings directly onto your current chart to help identify high-probability zones.

Price Data Components
Series array that contains close prices for each barSeries array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
5 Views
0 Downloads
0 Favorites
SVM_train_v02
//+------------------------------------------------------------------+
//|                                                      SVM_v04.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
#property indicator_level1 0


#define NR_OF_SAMPLE_LINES   4000
//#define NR_OF_TEST_LINES     100
//#define NR_OF_ATTRIB         9
#define FUTURE_WINDOW        100

#import "Project2.dll"
int Train(double t[],double c[],double l[],double h[],int,int,int,int,double,double &train_result[],double &train_time[]);
#import

extern int     TrainTimeFrame=PERIOD_M5;

double t[NR_OF_SAMPLE_LINES];
double c[NR_OF_SAMPLE_LINES];
double l[NR_OF_SAMPLE_LINES];
double h[NR_OF_SAMPLE_LINES]; 
/*        
double ma5_M5[NR_OF_SAMPLE_LINES];
double ma10_M5[NR_OF_SAMPLE_LINES];
double ma15_M5[NR_OF_SAMPLE_LINES];

double ma5_H1[NR_OF_SAMPLE_LINES];
double ma10_H1[NR_OF_SAMPLE_LINES];
double ma15_H1[NR_OF_SAMPLE_LINES];

double ma5_H4[NR_OF_SAMPLE_LINES];
double ma10_H4[NR_OF_SAMPLE_LINES];
double ma15_H4[NR_OF_SAMPLE_LINES];
*/
//double test_example_dyn_1[NR_OF_ATTRIB];
//double test_example_dyn_2[NR_OF_ATTRIB];
//double test_example_dyn_3[NR_OF_ATTRIB];

double train_result[NR_OF_SAMPLE_LINES];
double train_time[NR_OF_SAMPLE_LINES];


extern int StopLoss=60;
extern int TakeProfit=60;

double Buffer[];   
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  int xx;
//----
   IndicatorBuffers(1);
   SetIndexBuffer(0, Buffer);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   
   for(int i=0;i<NR_OF_SAMPLE_LINES;i++)
   {
      t[i]=iTime(NULL,TrainTimeFrame,i);
      c[i]=iClose(NULL,TrainTimeFrame,i);
      l[i]=iLow(NULL,TrainTimeFrame,i);
      h[i]=iHigh(NULL,TrainTimeFrame,i);

      //t[i]=iTime(NULL,PERIOD_H1,i);
      //c[i]=iClose(NULL,PERIOD_H1,i);
      //l[i]=iLow(NULL,PERIOD_H1,i);
      //h[i]=iHigh(NULL,PERIOD_H1,i);

 /*
      
      ma5_M5[i]=iMA(NULL,PERIOD_M5,5,0,MODE_SMA,PRICE_CLOSE,i);
      ma10_M5[i]=iMA(NULL,PERIOD_M5,10,0,MODE_SMA,PRICE_CLOSE,i);
      ma15_M5[i]=iMA(NULL,PERIOD_M5,15,0,MODE_SMA,PRICE_CLOSE,i);  

      ma5_H1[i]=iMA(NULL,PERIOD_H1,5,0,MODE_SMA,PRICE_CLOSE,i);
      ma10_H1[i]=iMA(NULL,PERIOD_H1,10,0,MODE_SMA,PRICE_CLOSE,i);
      ma15_H1[i]=iMA(NULL,PERIOD_H1,15,0,MODE_SMA,PRICE_CLOSE,i);  

      ma5_H4[i]=iMA(NULL,PERIOD_H4,5,0,MODE_SMA,PRICE_CLOSE,i);
      ma10_H4[i]=iMA(NULL,PERIOD_H4,10,0,MODE_SMA,PRICE_CLOSE,i);
      ma15_H4[i]=iMA(NULL,PERIOD_H4,15,0,MODE_SMA,PRICE_CLOSE,i);  
*/
      train_result[i]=0;
      train_time[i]=0;
   }
				
   xx=Train(t,c,l,h,NR_OF_SAMPLE_LINES,FUTURE_WINDOW,StopLoss,TakeProfit,Point,train_result,train_time);
   Print("Train: ",xx); 
/*
   string s1=""+
      train_result[0]+"\n"+
      train_result[1]+"\n"+
      train_result[2]+"\n"+
      train_result[3]+"\n"+
      train_result[4]+"\n"+
      train_result[53]+"\n"+
      train_result[16];
   Comment(s1);                                 
*/

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
    //  for(int i = 0; i < NR_OF_SAMPLE_LINES; i++)
    //   if(train_result[i]>-2)
    //     if(train_time[i]==Time[i])
    //       Buffer[i] = train_result[i];
           
  int x1,x2,x3;         
  int pos=0;
  pos=NR_OF_SAMPLE_LINES;
  while(pos>=0)
  //while(pos<=Bars)
   {  
       
      int pos1 = iBarShift(Symbol(), TrainTimeFrame, iTime(NULL,0,pos), true);
		if (iTime(Symbol(), TrainTimeFrame, pos1) == iTime(NULL,0,pos))  // have to be sure the times match.
		{ 
		  x1=train_result[pos];
		  if(x1>-2)
		    Buffer[pos]=x1; 
		}
		else
		{
		   if(x1>-2) 
			  Buffer[pos]=x1;   
		}
		   pos--;
	}	
           
  // Comment("");
  // Comment("Time[500]:",Time[500],"  train_time[500]:",(Period() * train_time[500]));
           
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments