Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools
Zurück   Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools > Metatrader 5 > Programmierung MQL5
Startseite Registrieren Hilfe Community Kalender Heutige Beiträge Suchen

Programmierung MQL5 Hier gehts rund ums Programmieren in MQL5.

Login
Benutzername:
Kennwort:


Statistik
Themen: 4978
Beiträge: 43261
Benutzer: 7.223
Aktive Benutzer: 74
Links: 84
Wir begrüßen unseren neuesten Benutzer: Sundaytrader
Mit 2.475 Benutzern waren die meisten Benutzer gleichzeitig online (16.01.20 um 22:38).
Neue Benutzer:
vor einer Woche
- Sundaytrad...
vor einer Woche
- TS_6
vor einer Woche
- Mane
vor 3 Wochen
- AlbertZiz
vor 3 Wochen
- michak

Onlineuser
'Wer ist online' anzeigen Benutzer: 0
Gäste: 435
Gesamt: 435
Team: 0
Team:  
Benutzer:  
Freunde anzeigen

Empfehlungen

Thema geschlossen
 
Themen-Optionen Thema durchsuchen Ansicht
  #1 (permalink)  
Alt 03.10.23
Neues Mitglied
 
Registriert seit: Oct 2023
Beiträge: 1
CodeNewbie befindet sich auf einem aufstrebenden Ast
Standard Hilfe bei Expert Advisor.

Hallo. Versuche mich an einem EA. Aber leider nimmt er die trade.Sell und trade.buy Funktion leider nicht. Könnte mir dabei jemand behilflich sein wo mein Fehler liegt? Hier der Code.

#include <Trade\Trade.mqh>

CTrade trade;

input int stopLossPips = 150; // Stop Loss in Pips
input int takeProfitPips = 200; // Take Profit in Pips
input int trailStopPips = 10; // Trailing Stop in Pips

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Initialize your EA here
return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
// Deinitialize your EA here
}

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBO L_ASK),_Digits);
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBO L_BID),_Digits);

//--- Fractal variables
double fractalHigh, fractalLow;
string signal="";

fractalHigh = iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 5, 1));
fractalLow = iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 5, 1));

if((iHigh(Symbol(), 0, 2) < iHigh(Symbol(), 0, 1) && iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 0)) && (iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 3) && iHigh(Symbol(), 0, 1) > iHigh(Symbol(), 0, 4)))
{
fractalHigh = iHigh(Symbol(), 0, 1);
signal="sell";
}

if((iLow(Symbol(), 0, 2) > iLow(Symbol(), 0, 1) && iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 0)) && (iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 3) && iLow(Symbol(), 0, 1) < iLow(Symbol(), 0, 4)))
{
fractalLow = iLow(Symbol(), 0, 1);
signal="buy";
}

//--- Buy condition
if(fractalLow != 0)
{
double stopLoss = fractalLow - stopLossPips * _Point;
double takeProfit = fractalLow + takeProfitPips * _Point;
double trailingStop = fractalLow - trailStopPips * _Point;

// Retrieve the current Ask price
if (signal =="buy" && PositionsTotal()<1)
{
// Place buy order here using Ask
trade.Buy(0.10,NULL,Ask,(Ask-200 * _Point),(Ask+150 * _Point),NULL, stopLoss, takeProfit, trailingStop);
}
}

//--- Sell condition
if(fractalHigh != 0)
{
double stopLoss = fractalHigh + stopLossPips * _Point;
double takeProfit = fractalHigh - takeProfitPips * _Point;
double trailingStop = fractalHigh + trailStopPips * _Point;

// Retrieve the current Bid price
if (signal =="sell" && PositionsTotal()<1)
{
// Place sell order here using Bid
trade.Sell(0.10,NULL,Bid,(Bid+200 * _Point),(Bid-150 * _Point),NULL, stopLoss, takeProfit, trailingStop);
}
}
}
  #2 (permalink)  
Alt 04.10.23
Benutzerbild von Indikator-Trading
Premium Mitglied
 
Registriert seit: May 2020
Ort: Bielefeld
Beiträge: 345
Indikator-Trading befindet sich auf einem aufstrebenden Ast
Standard

Hier ist die Funktion, welche du aufrufen willst:

bool Sell(
double volume, // Volumen der Position
const string symbol=NULL, // Symbol
double price=0.0, // Ausführungspreis
double sl=0.0, // Preis von Stop Loss
double tp=0.0, // Preis von Take Profit
const string comment="" // Kommentar
)

d.h. dein Aufruf von

trade.Sell(0.10,NULL,Bid,(Bid+200 * _Point),(Bid-150 * _Point),NULL, stopLoss, takeProfit, trailingStop);

hat zuviele und falsche Parameter:

volume = 0.10;
symbol = NULL;
price = Bid;
sl = (Bid+200 * _Point);
tp = (Bid-150 * _Point);
comment = NULL;
Diese sind so ok, allerdings sind da jetzt noch "stopLoss, takeProfit, trailingStop);" mit dran und damit kann die Funktion nichts anfangen
Thema geschlossen

Lesezeichen


Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus




Alle Zeitangaben in WEZ +2. Es ist jetzt 08:04 Uhr.





Suchmaschine - Reisen - Wavesnode - Facebook Forum - Spam Firewall
-----------------------------------------------------------------------------------------------------------------------------
Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
SEO by vBSEO 3.6.1
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum
MetaTrader bzw. MetaTrader 4 und MetaTrader 5 sind eingetragene Marken der MetaQuotes Software Corp.
-----------------------------------------------------------------------------------------------------------------------------