| |
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
// AG_AT.mq4 Example 9 (instruments 12)
// Custom Automatic Trade function.
// Used at the construction of automatic trade strategy for application AutoGraf 4
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
// It is not realization of trade strategy. It is a technical example of management ..
// .. instruments for the construction of the own automatic trade system.
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж 0 жж
#property library
#import "AG_Lib.ex4"
int AG_Magic_Number();
// Magic Number calculation
int AG_Message(string& Message[], string _Text);// Text messages record in Message[]
// Control action record in Manager[][]
int AG_Set_Instr(double& Manager[][], int ii, double v1, double v2, double v3,
double v4, double v5, double v6, int io , int ih);
int AG_Delete_Instr(double&Manager[][], int ii, int io,int ih);// Deleting of instruments
#import "AG_Trade_Criterion.ex4"
int AG_Trade_Criterion_1();// First function of trade criterion definition
int AG_Trade_Criterion_2();// Second function of trade criterion definition
#import
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж 1 жж
int AG_AT(int Parol_AT, double Order[][], string Object[], double Instrument[][][][],
int Ddraw_Object[][], double& Tuning[], double& Manager[][], string& Message[])
{
//================================================================================== 2 ==
if (!IsDemo()) // For demo account without limits
{
if(Parol_AT != AccountNumber() + 1) // If incorrect password enter
{ // Example of message (max 62 symbols)
AG_Message(Message, "Developer J.Smith, http://company.com ");
AG_Message(Message, "Incorrect password for AT function.");
return(0);// Exit from AT function
} // AT function will automatic turn off by AutoGraf
}
//================================================================================== 3 ==
static int Count = 0; // Counter
int MN; // MagicNumber it is recommended to calculate in AG_Magic_Number() function
static int Ticket; // Unique identifier of order
string Comm = "AG_AT";// Commentary (it is recommended "AG_AT")
//==================================================================================
double Lot = NormalizeDouble(Tuning[1]],2); // Value of lots
int Per = NormalizeDouble(Tuning[2],0); // Value of percents (integer)
int Slip = NormalizeDouble(Tuning[3],0); // Slippage (in points)
int SL = NormalizeDouble(Tuning[4],0); // StopLoss (in points)
int TP = NormalizeDouble(Tuning[5],0); // TakeProfit (in points)
int Ds = NormalizeDouble(Tuning[6],0); // Distance (in points)
int St = NormalizeDouble(Tuning[7],0);// Modification step (in points)
//================================================================================== 4== if (Count==0) // It can be done one time at the beginning
{// Example of message (max 62 symbols):
AG_Message(Message, "Developer J.Smith, http://company.com ");
Count++; // Amount of visits of this block
Lot = 0.0;// 0.0 means that the lots amount is calculated in AutoGraf
Per = 7; // .. on the basis of value percent (here 7%) of sum of balance
Slip = 1;
SL = 100;
TP = 75;
Ds = 20;
St = 3;
//================================================================================== 5== Tuning[1] = Lot; // Lots value
Tuning[2] = Per; // Value of percents (integer)
Tuning[3] = Slip; // Slippage (in points)
Tuning[4] = SL; // StopLoss (in points)
Tuning[5] = TP; // TakeProfit (in points)
Tuning[6] = Ds; // Distance (in points)
Tuning[7] = St;// Modification step (in points)
AG_Message(Message,"Changing of options from АТ..");// Example of message (max. 62 chars.)
return(1); // Exit after retuning of parameters
}
// After a control from AG_AT will be returned..
// .. in application AutoGraf, in the AG_ind indicators ..
// ... window is possible to look new values of tunings.
//================================================================================== 6 ==
bool Channal = false; // The object of the set type is not present
bool Manage_12 = false;
// The object of the set type is not appointed under the management of instrument 1
int Obj_Total_AG = StrToInteger(Object[0]);// Amount of objects, examined in AG 4
for(int k=1; k<=Obj_Total_AG; k++) // We will walk on the examined objects
{
// (for the practical use more thorough analysis is required)
string His_Name = Object[k]; // Name of current object
if (ObjectType(His_Name) == OBJ_STDDEVCHANNEL)// it is possible also OBJ_REGRESSION
{
// On the array of objects, guided by an instrument 12
for(int i=1; i<=Ddraw_Object[0][0]; i++)
{
if(k == Ddraw_Object[i][0])
// If an object is already appointed under the management of instrument 12
{
Manage_12 = true;
// Fact, that this object already under the management of instrument 12
break; // An object is found, farther to search there is not a necessity
}
}
Channal = true; // Fact, that the object of such type already is present in a window
break; // We terminate a loop of search of objects (we take away an index k)
}
}
//================================================================================== 7 ==
if (Channal == false) // If the object of the set type is not present
{
string My_Chan_Name = "Channel_for_AT"; // Name of the created channel
ObjectCreate (My_Chan_Name, OBJ_STDDEVCHANNEL,0,0,0); // We create him ..
int Сoor_X2 = Time[0];// 1-st point on the left, 2-nd point on the right
int Сoor_X1 = Сoor_X2 - 24*60*60; // Duration of channel is twenty-four hours
//Channel for the practical use it is necessary to calculate through bars
ObjectSet(My_Chan_Name, OBJPROP_TIME1, Сoor_X1); // We set co-ordinates
ObjectSet(My_Chan_Name, OBJPROP_TIME2, Сoor_X2); // We set co-ordinates
ObjectSet(My_Chan_Name, OBJPROP_COLOR, Orange); // We set co-ordinates
AG_Message(Message, "АТ: We set an object OBJ_STDDEVCHANNEL.");// Message
return(1); // It is necessary, that the set channel was accounting in AG 4
}
if (Manage_12 == false) // An object is, but not appointed under management of instrument 12
{ // We set an instrument 12 Pull_Object on a channel
AG_Set_Instr(Manager, 12, 0, 0, 0, 0, 0, 0, k, 0);
AG_Message(Message, "АТ: We set an instrument Pull_Object.");// Message
}
//================================================================================== 8 ==
return(1);
}
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж End of module жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж 9 жж
|
|