Premetto che prima di imparare a programmare vorrei imparare a gestire le opzioni in modo corretto .....ad ogni modo nel lontano 1998 in un paio di lezioni mi hanno introdotto al turbopascal (se non ho capito male è uno dei due linguaggi accettati da FPSS) e già all'epoca mi domandavo a cosa mi sarebbe potuto servire saper programmare....bhe oggi ho la risposta!
Venendo a concetti piu' operativi tempo fà ho utilizzato un software per MT4 che genera codice in automatico, vi incollo uno script molto semplice che lavora sulle EMA, qualcuno mi sa dire che linguaggio è e soprattutto se secondo voi è fattibile fare un copia/incolla dal codice prodotto in automatico allo script di FiutoPro??? Ok...non sarà ottimizzato e scritto in modo elegante ma se gira direi che è un ottimo compromesso!!!
//-------------------------------------------------------------
// Etasoft Inc. Forex EA and Script Generator version 4.4 EA
//-------------------------------------------------------------
// Keywords: MT4, Forex EA builder, create EA, expert advisor developer
#property copyright "Copyright © 2011, Etasoft Inc. Forex EA Generator v4.4"
#property link "http://www.forexgenerator.com/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
// exported variables
extern double BuyLots13 = 0.1;
extern int BuyStoploss13 = 50;
extern int BuyTakeprofit13 = 100;
extern double SellLots14 = 0.1;
extern int SellStoploss14 = 50;
extern int SellTakeprofit14 = 100;
// local variables
double PipValue=1; // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n"; // use this in custom or utility blocks where you need line feeds
int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;
int init()
{
NDigits = Digits;
if (false) ObjectsDeleteAll(); // clear the chart
Comment(""); // clear the chart
}
// Expert start
int start()
{
if (Bars < 10)
{
Comment("Not enough bars");
return (0);
}
if (Terminated == true)
{
Comment("EA Terminated.");
return (0);
}
OnEveryTick1();
}
void OnEveryTick1()
{
if (true == false && true) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
TechnicalAnalysis3x5();
TechnicalAnalysis3x23();
}
void TechnicalAnalysis3x5()
{
if ((iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,0) > iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,1)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,1) > iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,2)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,2) > iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,3)))
{
TechnicalAnalysis3x22();
}
}
void TechnicalAnalysis3x22()
{
if ((iMA(NULL, PERIOD_M30,25,0,MODE_EMA,PRICE_MEDIAN,0) > iMA(NULL, PERIOD_M30,50,0,MODE_EMA,PRICE_MEDIAN,0)) && (iMA(NULL, PERIOD_M30,25,0,MODE_EMA,PRICE_MEDIAN,1) < iMA(NULL, PERIOD_M30,50,0,MODE_EMA,PRICE_MEDIAN,1)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,0) > iMA(NULL, PERIOD_H4,200,0,MODE_EMA,PRICE_MEDIAN,0)))
{
BuyOrder13();
}
}
void BuyOrder13()
{
double SL = Ask - BuyStoploss13*PipValue*Point;
if (BuyStoploss13 == 0) SL = 0;
double TP = Ask + BuyTakeprofit13*PipValue*Point;
if (BuyTakeprofit13 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, BuyLots13, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, BuyLots13, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
void TechnicalAnalysis3x23()
{
if ((iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,0) < iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,1)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,1) > iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,2)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,2) < iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,3)))
{
TechnicalAnalysis3x10();
}
}
void TechnicalAnalysis3x10()
{
if ((iMA(NULL, PERIOD_M30,25,0,MODE_EMA,PRICE_MEDIAN,0) < iMA(NULL, PERIOD_M30,50,0,MODE_EMA,PRICE_MEDIAN,0)) && (iMA(NULL, PERIOD_M30,25,0,MODE_EMA,PRICE_MEDIAN,1) < iMA(NULL, PERIOD_M30,50,0,MODE_EMA,PRICE_MEDIAN,1)) && (iMA(NULL, PERIOD_H4,50,0,MODE_EMA,PRICE_MEDIAN,0) < iMA(NULL, PERIOD_H4,200,0,MODE_EMA,PRICE_MEDIAN,0)))
{
SellOrder14();
}
}
void SellOrder14()
{
double SL = Bid + SellStoploss14*PipValue*Point;
if (SellStoploss14 == 0) SL = 0;
double TP = Bid - SellTakeprofit14*PipValue*Point;
if (SellTakeprofit14 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, SellLots14, Bid, 4, 0, 0, "My Expert", 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, SellLots14, Bid, 4, SL, TP, "My Expert", 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
int deinit()
{
if (false) ObjectsDeleteAll();
}