На всякий случай прилагаю код советника
Код: Выделить всё
//--------------------------------------------------------------------------
// Some info
//--------------------------------------------------------------------------
#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include "Graphics.h"
#include "time.h"
#include "ctime"
// external parameters
int Hours = 7;
int Minutes = 30;
PChar Buy_or_Sell = NULL;
double TakeProfit = 100;
double StopLoss = 100;
int DayToOpen = 1;
double Lots = 1.0;
PChar Currency = NULL;
// internal variables
int MagicNumber = 140791;
bool IsOrder;
bool flag;
bool IsOrderClosed;
//Работа со временем
int w_min, w_wday, w_hour, w_year, w_month, w_day;
char buff[200];
void EstablishDateTimeValues()
{
time_t mytime; // define structure of type time_t, c++ base date is 01/01/1970 (25569 days after FT start date of 30/12/1899)
mytime = (time_t) ((iTime(Symbol(),1,0) - 25569) * 86400); // Convert FT date/time to c++ equivalent
struct tm * timeinfo; // define local structure 'tm' to hold calendar date in component parts
timeinfo = gmtime(&mytime); // Copy that time to modifiable structure 'timeinfo (note GMT)
w_year = 1900 + timeinfo->tm_year; // save year, adjusted (years since 1900)
w_month = 1 + timeinfo->tm_mon; // save month number, adjusted (runs 0 - 11)
w_day = timeinfo->tm_mday; // save day of month (runs 1 - 31)
w_wday = timeinfo->tm_wday; // save day of week (runs 0 - 6, sunday=0)
w_hour = timeinfo->tm_hour; // save hour of day (runs 0 - 23)
w_min = timeinfo->tm_min; // save minute of hour (runs 0 - 59)
mktime ( timeinfo ); // call mktime to set timeinfo structure variables
}
//-----Init strategy----------------------------------------------------------
EXPORT void __stdcall InitStrategy()
{
StrategyShortName("OrderByWeek");
StrategyDescription("Odin order v nedelu");
RegOption("Hours", ot_Integer, &Hours);
SetOptionRange("Hours",0, 23);
RegOption("Minutes", ot_Integer, &Minutes);
SetOptionRange("Minutes",0, 59);
RegOption("Buy_or_Sell", ot_String, &Buy_or_Sell);
Buy_or_Sell = "b";
RegOption("TakeProfit", ot_double, &TakeProfit);
SetOptionDigits("TakeProfit", 2);
RegOption("StopLoss", ot_double, &StopLoss);
SetOptionDigits("StopLoss", 2);
RegOption("DayToOpen", ot_Integer, &DayToOpen);
SetOptionRange("DayToOpen",1, 5);
RegOption("Lots", ot_double, &Lots);
RegOption("Currency", ot_Currency, &Currency);
IsOrder = false;
TakeProfit *=10;
StopLoss *=10;
EstablishDateTimeValues();
}
//-----Done strategy----------------------------------------------------------
EXPORT void __stdcall DoneStrategy()
{
//
}
//-----Reset strategy---------------------------------------------------------
EXPORT void __stdcall ResetStrategy()
{
//
}
//-----Process single tick----------------------------------------------------
EXPORT void __stdcall GetSingleTick()
{
//
if (strcmp(Currency, Symbol()) != 0) return;
EstablishDateTimeValues();
int t;
if(w_wday == DayToOpen)
{
if(w_hour == Hours && w_min>=Minutes)
{
if(!IsOrder)
{
if((Buy_or_Sell == "b") || (Buy_or_Sell == "B"))
{
SendInstantOrder(Symbol(),op_Buy,Lots,Ask() - StopLoss * Point(), Ask() + TakeProfit * Point(),"Order",MagicNumber,t);
}
if((Buy_or_Sell == "s") || (Buy_or_Sell == "S"))
{
SendInstantOrder(Symbol(),op_Sell,Lots,Bid() + StopLoss * Point(), Bid() - TakeProfit * Point(),"Order",MagicNumber,t);
}
IsOrder = true;
}
}
}
if(OrdersTotal() == 0)
IsOrder = false;
}