klassifiziertes globales Array mit iCustom

 
Sehr geschätzte Community,
kann man durch Aufruf eine Indikators mit iCustom ein klassifiziertes globales Array als zusätzlichen Parameter übergeben?
Mir geht‘s speziell darum nicht mit GlobalVariableSet(), sondern objektorientiert mit globalen Variablen arbeiten zu können.

Vielen Dank für eure Hilfe!
 
Joosy:
Sehr geschätzte Community,
kann man durch Aufruf eine Indikators mit iCustom ein klassifiziertes globales Array als zusätzlichen Parameter übergeben?
Mir geht‘s speziell darum nicht mit GlobalVariableSet(), sondern objektorientiert mit globalen Variablen arbeiten zu können.

Vielen Dank für eure Hilfe!

Da brauchst du keinen Indikator, du definierst eine Klasse in einer mqh.

Du kannst auch eine Klasse von CTrade ableiten, die so ziemlich alles enthalten kann was du so benötigst.

Hier Codefragmente:

class CTradeExt : public CTrade     // defines the class derived from CTrade
{
   public:                          // static public vars set by constructor
      string   ProgName;            // name of program
      double   VolMin;              // Minimal volume for a deal
      double   VolMax;              // Maximal volume for a deal
      double   VolStep;             // Minimal volume change step for deal execution
      double   TickSize;            // Minimal price change
      double   TickValue;           // Value of SYMBOL_TRADE_TICK_VALUE_PROFIT
      int      StopLevel;           // Minimal indention in points from the current close price to place Stop orders
   public:                          // dynamic public vars updated by OnTick()
      double   SwapLong;            // Long swap value
      double   SwapShort;           // Short swap value
      
      double   AccBalance;          // Account balance in the deposit currency
      double   AccEquity;           // Account equity in the deposit currency
      int      AccLeverage;         // Account leverage
      double   AccMarginFree;       // Free margin of an account in the deposit currency
      double   AccMarginLevel;      // Account margin level in percents
      
      double   Ask;                 // current ASK price
      double   Bid;                 // current BID price
      long     Spread;              // current Spread value in points

      bool     PosOpened;
      POSTYPE  PosType;
      long     PosTicket;
      double   PosVolume;
      double   PosOpenPrice;
      datetime PosOpenTime;
      double   PosProfit;
      double   PosSL;
      double   PosTP;
//..........
}


void CTradeExt::CTradeExt(void)     // Constructor - get static information from account and symbol
{
   ProgName          = MQLInfoString    (MQL_PROGRAM_NAME);
   VolMin            = SymbolInfoDouble (_Symbol,SYMBOL_VOLUME_MIN);
   VolMax            = SymbolInfoDouble (_Symbol,SYMBOL_VOLUME_MAX);
   VolStep           = SymbolInfoDouble (_Symbol,SYMBOL_VOLUME_STEP);
   TickSize          = SymbolInfoDouble (_Symbol,SYMBOL_TRADE_TICK_SIZE);
   StopLevel         = (int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
   AccLeverage       = (int)AccountInfoInteger(ACCOUNT_LEVERAGE);
   TickIndex         = -1;
   BarsIndex         = -1;
   requestInit       = true;
   requestReset      = true;
}

bool CTradeExt::OnTick()   // get dynamic information from symbol, account and position
{
   TickIndex++;            // tick counter for debugging purpose

   AccBalance        = AccountInfoDouble(ACCOUNT_BALANCE);
   AccEquity         = AccountInfoDouble(ACCOUNT_EQUITY);
   AccMarginFree     = AccountInfoDouble(ACCOUNT_MARGIN_FREE);
   AccMarginLevel    = AccountInfoDouble(ACCOUNT_MARGIN_LEVEL);
   
   Ask               = SymbolInfoDouble (_Symbol,SYMBOL_ASK);
   Bid               = SymbolInfoDouble (_Symbol,SYMBOL_BID); 
   Spread            = SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);

//...........
}

Da kannst du natürlich auch Arrays hineinpacken.

 
Otto Pauser:

Da brauchst du keinen Indikator, du definierst eine Klasse in einer mqh.

Du kannst auch eine Klasse von CTrade ableiten, die so ziemlich alles enthalten kann was du so benötigst.

Hier Codefragmente:


Da kannst du natürlich auch Arrays hineinpacken.

Servus Otto Pauser,
Danke für die Hilfe. Ich muss mich allerdings für meine unklare Formulierung entschuldigen. Ich rufe einen Indikator durch iCustom auf und analysiere darin ein bestimmtes Momentum. Diesen Price möchte ich wieder an das aufrufende Programm zurückgeben. Ich benötige dafür eine globale Datenschnittstelle. So ähnlich wie z.B. iCustom(...,...,.. &myGlobalVariableClass)

Danke!


Gruß
Joosy

 

ich verstehe dich nicht, wenn du einen Indikator mit iCustom einbindest dann hast Du die Werte ja auch im EA.

Für den Fall das du diesen in einer Funktion laufen hast, dann kannst du ja den Rückgabewert was du brauchst in die return(rückgabewert) reinschreiben.

Die initialisierung des Indi sollte sowieso über onInit laufen


amando

 
Joosy:

Servus Otto Pauser,
Danke für die Hilfe. Ich muss mich allerdings für meine unklare Formulierung entschuldigen. Ich rufe einen Indikator durch iCustom auf und analysiere darin ein bestimmtes Momentum. Diesen Price möchte ich wieder an das aufrufende Programm zurückgeben. Ich benötige dafür eine globale Datenschnittstelle. So ähnlich wie z.B. iCustom(...,...,.. &myGlobalVariableClass)

Danke!


Gruß
Joosy

Ich glaube, das geht nur, wenn Du es Dir selber schnitzt, äh programmierst.
 

Du kannst das auch mit Messages machen (hab ich mal was dazu gepostet. EventChartCustom(...) ist die Funktion die sendet) falls du die Globalvariablen nicht verwenden willst.

Empfangen wird mit OnChartEvent(...).

Mit Messages geht es sicher schneller als mit Globalvariablen

Grund der Beschwerde: