1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#define WIN32_LEAN_AND_MEAN
#define mt4 _declspec(dllexport)
//the g_ in front of the variable HAS to be there.
struct SymbolData{double ask; double bid; double point; int spread; int distance; int spreadProtect;};
#pragma data_seg (".EURUSD")
SymbolData g_ibfx={0.0,0.0,0.0,0,0,0};
SymbolData g_alpari={0.0,0.0,0.0,0,0,0};
#pragma data_seg()
#pragma comment(linker, "/SECTION:.EURUSD,RWS")
mt4 int _stdcall set_ibfx(double a, double b, double p, int s, int d, int sp)
{
//set values needed.
g_ibfx.ask=a;
g_ibfx.bid=b;
g_ibfx.point=p;
g_ibfx.spread=s;
g_ibfx.distance=d;
g_ibfx.spreadProtect=sp;
if (g_alpari.ask==0) {return 0;}
return get_signal(a,b,g_alpari.ask,g_alpari.bid,p,s,d,sp);
}
mt4 int _stdcall set_alpari(double a, double b, double p, int s, int d, int sp)
{
//set values needed.
g_alpari.ask=a;
g_alpari.bid=b;
g_alpari.point=p;
g_alpari.spread=s;
g_alpari.distance=d;
g_alpari.spreadProtect=sp;
if (g_ibfx.ask==0) {return 0;}
return get_signal(a,b,g_ibfx.ask,g_ibfx.bid,p,s,d,sp);
}
int get_signal (double homeAsk, double homeBid, double awayAsk, double awayBid, double point, int spread, int distance, int spreadprotect)
{
static int returnvalue=3;
static bool bSpread=true;
//no data
if (awayAsk=0) {return 0;}
//check spread
if (spread>spreadprotect) {bSpread=false;}
//check direction
if (homeAsk < awayBid && bSpread && (awayBid-homeAsk)/point > distance) {returnvalue=1;} //long
if (homeBid > awayAsk && bSpread && (awayAsk-homeBid)/point > distance) {returnvalue=2;} //short
if (homeAsk < awayBid && bSpread && (awayBid-homeAsk)/point < distance) {returnvalue=0;} //continued long
if (homeBid > awayAsk && bSpread && (awayAsk-homeBid)/point < distance) {returnvalue=0;} //continued short
return returnvalue;
}
|