Es ist ein oft gelöstes Problem. Such mal nach newBar und dann CodeBase oder Artikel links auswählen.
Im Datenfenster kann man sich diesen Wert nicht ausgeben lassen da Sonderzeichen enthalten sind.
Aber bei jeder neuen Kerze den Wert mit Print oder Comment ausgeben lassen ist möglich.
#property copyright "Copyright 2023, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot IPadress #property indicator_label1 "IPadress" #property indicator_type1 DRAW_NONE #property indicator_width1 1 #include <mql4-http.mqh> //--- indicator buffers double IPadressBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { string myIP = httpGET("http://icanhazip.com/"); Print(myIP); //--- indicator buffers mapping SetIndexBuffer(0,IPadressBuffer); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //---Variable zur Berechnung den Anfang des Bars int starts=prev_calculated; //--- wen die Indikatorwerte auf vorhergehend Tick schon berechnet waren, so ist auf der letzten Bar gearbeitet if(prev_calculated>0) starts--; for(int i=starts; i<rates_total-1 && !IsStopped(); i++) { if((Volume[0])==1) { string myIP = httpGET("http://icanhazip.com/"); Print(myIP); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Wozu braucht man das eigentlich?
Sie verpassen Handelsmöglichkeiten:
- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Registrierung
Einloggen
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
Wenn Sie kein Benutzerkonto haben, registrieren Sie sich
Hallo,
ich habe den Indikator unten erstellt. Dieser funktioniert auch soweit.
Im Sekundentakt (oder schneller) wird meine IP (oder irgendein anderer abgerufener Wert) im Terminal ausgegeben.
Ziel ist jedoch folgendes:
Dass der Wert "myIP" nur einmal pro Balken abgerufen wird und im Datenfenster angezeigt.
Ich glaube dies sollte sehr einfach sein, ich bekomme es jedoch nicht hin.
Kann mir jemand helfen?
//+------------------------------------------------------------------+
//| http.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#include <mql4-http.mqh>
int OnInit () {
string myIP = httpGET("http://icanhazip.com/");
Print(myIP);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+