Author: Copyright 2007, Ralph Ronnquist
Via

This technical tool is designed to analyze market relationships by calculating a combined "synthetic" value based on the interaction between your current trading pair and a specific third currency. Essentially, it creates a custom price line that helps traders visualize how external factors—like the strength of a major currency—are influencing their primary trade.

How the Logic Works

1. Dynamic Pair Identification When you apply this tool to a chart (for example, GBP/USD), the script automatically identifies the underlying components of the pair. It then looks for the "cross" involving your chosen base currency (like EUR). If the market data isn't formatted standardly, the script is smart enough to flip the currency order automatically to ensure it always finds the correct data to calculate.

2. Synthetic Price Generation Instead of just looking at the price on your screen, the indicator calculates a new value by multiplying the price of one component of your current pair by the chosen "Via" currency. This results in a unique price line (plotted as a silver line on your chart). This line represents a specialized correlation; it effectively filters out some of the "noise" of the standard market to show a smoother movement based on the two currencies involved.

3. Visual Buy and Sell Signals The tool provides automated visual cues in the form of arrows:

  • Buy Signals (Blue Arrows): The script looks for moments where the synthetic price line moves significantly above the previous candle's high. It specifically checks if the move is large enough to clear the current market spread plus a user-defined "profit" buffer.
  • Sell Signals (Red Arrows): Conversely, it monitors for instances where the synthetic price line drops significantly below the previous candle’s low, again accounting for the spread and your preferred profit margin.

Key Features for the User

  • Customizable Buffer: You can adjust an "offset" to shift the calculated line up or down slightly.
  • Profit Adjustment: A built-in setting allows you to define a "profit" buffer, ensuring that signals are only triggered when the price movement is significant enough to be meaningful.
  • Real-time Monitoring: The tool calculates these values across your historical chart data and updates dynamically as new price candles form, providing a continuous stream of correlation data and potential entry points.
Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Via
//+------------------------------------------------------------------+
//|                                                          Via.mq4 |
//|                                  Copyright 2007, Ralph Ronnquist |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2007, Ralph Ronnquist"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 Blue
#property indicator_color3 Red

//---- input parameters
extern string    via="EUR";
extern int offset = 0;
extern int profit = 4;
//---- indicator buffers
double price[];
double buy[];
double sell[];

//---- variables
string XXXvia;
string viaYYY;
bool Xinvert = false;
bool Yinvert = false;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    SetIndexStyle( 0, DRAW_LINE );
    SetIndexBuffer( 0, price );
    SetIndexEmptyValue( 0, 0 );

    SetIndexStyle( 1, DRAW_ARROW );
    SetIndexArrow( 1, 241 );
    SetIndexBuffer( 1, buy );
    SetIndexEmptyValue( 1, 0 );

    SetIndexStyle( 2, DRAW_ARROW );
    SetIndexArrow( 2, 242 );
    SetIndexBuffer( 2, sell );
    SetIndexEmptyValue( 2, 0 );

    // Figure out the crossed symbols
    string XXX = StringSubstr( Symbol(), 0, 3 );
    string YYY = StringSubstr( Symbol(), 3, 3 );
    XXXvia = StringConcatenate( XXX, via );
    viaYYY = StringConcatenate( via, YYY );
    int a = MarketInfo( XXXvia, MODE_DIGITS );
    if ( a == 0 ) {
        XXXvia = StringConcatenate( via, XXX );
        Xinvert = true;
        a = MarketInfo( XXXvia, MODE_DIGITS );
    }
    
    int b = MarketInfo( viaYYY, MODE_DIGITS );
    if ( b == 0 ) {
        viaYYY = StringConcatenate( YYY, via );
        Yinvert = true;
        b = MarketInfo( viaYYY, MODE_DIGITS );
    }
    Print( "Presenting " + XXXvia + "*" + viaYYY + " " + a + " " + b );
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
    for ( int bar = Bars - IndicatorCounted(); bar >= 0; bar-- ) {
        indicate( bar );
    }
    return(0);
}

double getPrice(string symbol,int bar,bool invert)
{
    double a = iClose( symbol, Period(), bar );
    if ( a == 0 ) {
        Comment( symbol + " not loaded for " + bar );
        return( 0 );
    }
    if ( invert )
        return ( 1 / a );
    return ( a );
}

void indicate(int bar)
{
    double a = getPrice( XXXvia, bar, Xinvert );
    double b = getPrice( viaYYY, bar, Yinvert );
    price[ bar ] = NormalizeDouble( a * b, Digits ) + offset * Point;
    Comment( price[ bar ] );
    
    buy[ bar ] = 0;
    double level = Close[ bar+1 ] + ( MarketInfo( Symbol(), MODE_SPREAD ) + profit ) * Point;
    if ( price[ bar+1 ] > level && price[ bar+1 ] > High[ bar+1 ] )
        buy[ bar ] = price[ bar+1 ];

    sell[ bar ] = 0;
    level = price[ bar+1 ] + ( MarketInfo( Symbol(), MODE_SPREAD ) + profit ) * Point;
    if ( level < Close[ bar+1 ] && level < Low[ bar+1 ] )
        sell[ bar ] = price[ bar+1 ];

}

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

Comments