I am trying to create a textfile with MQL4. No sucess. It just doesn't work. A very simple script:
void OnStart() {
string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
string filename=terminal_data_path+"\\MQL4\\Files\\"+"teste2.txt";
int filehandle = FileOpen(filename,FILE_WRITE|FILE_TXT);
FileWriteString(filehandle,"teste");
FileClose(filehandle);
}
This fires error 5002. OK, the file does not exist. I thinked that the script will create the file.
So, I decided to create an empity "teste2.txt" with notepad in the folder. The same error.
Can someone help me?
Thanks
The file is written by default in .../MQL4/Files, so just writting that code works (it creates a file named teste2.txt with teste written in it in .../MQL4/Files) :
void OnStart()
{
int filehandle = FileOpen("teste2.txt",FILE_WRITE|FILE_TXT);
FileWriteString(filehandle,"teste");
FileClose(filehandle);
}
Of course you will need to check the return of the FileX functions (FileOpen, fileWrite, FileClose, etc)
if you call your file string filename="A"+"\\B\\"+"teste2.txt"; it will be written into TerminalInfoString(TERMINAL_DATA_PATH)\MQL4\Files\A\B\ folders. Of course you cannot use prohibited symbols in the file name, and ":\" from the full path (C:\Users\User_NAME\AppData...) is prohibited
First, you need to check to see if there's a file.
//+------------------------------------------------------------------+
//| FileIsExist.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
string filename = "teste2.txt";
int fileHandle ;
if(FileIsExist(filename,0))
{
Print("Specified File Has");
fileHandle = FileOpen(filename , FILE_WRITE|FILE_TXT);
FileWriteString(fileHandle,"teste");
FileClose(fileHandle);
Print("Write to Existing File Completed");
}else
{
Print("File Not Available, Regenerating....." );
fileHandle = FileOpen(filename , FILE_READ|FILE_WRITE|FILE_TXT);
FileWriteString(fileHandle,"Writing to Newly Created File Completed - teste \n");
FileClose(fileHandle);
Print("Writing to Newly Created File Completed");
}
}
//+------------------------------------------------------------------+
Related
am Trying To Code an EA has This Jobs dealing with Boom 1000 index
Set Limited Order (Buy \ Sell)
and The Orders moving with the price in that way:
if the price goes down the buy stop will follow each candle for waiting for the bullish candle, and the same thing for the sell order
I have this problem:
the orders repeating if I close the EA or I changed the frame
"I have a problem with deinitialization"
I have no idea how can I let the order move with each candle
"adjust the order
the code I have used:
//+------------------------------------------------------------------+
//| EABoom1000Scalper.mq5 |
//| Copyright 2022, OshGroup ltd. |
//| https://oshgrp.com/ar |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, OshGroup ltd."
#property link "https://oshgrp.com/ar"
#property version "1.01"
#property description "Note:The EA Work with Buy and Sell\n"
#property description "If You Dont Need TP Or SL just let it 0 "
#property description "Try Version N10 Will destroy after 7 days"
//+-----------------Include--------------------------------+
#include <Trade/Trade.mqh>
#include <Expert\Expert.mqh>
#include <Expert\Signal\SignalMA.mqh>
#include <Expert\Trailing\TrailingParabolicSAR.mqh>
#include <Expert\Money\MoneySizeOptimized.mqh>
//+-----------------------Enumoration------------------------------+
enum TradeAutoOption{
Yes=0,
No=1
};
enum Trade_Type{
BUY=0, SELL=1
}
;
enum SYMBOL_ASK_O{
Boom_Index_1000=0, Crash_Index_1000=1, Boom_Index_500=2, Crash_Index_500=3
};
//+--------------------input parameters-----------------------+
input group "Setting"
input string Inp_Expert_Title ="ScalperExpert";
input group "Trade Type"
input Trade_Type Ordder_Type =BUY;
input group "Order_Details"
input double LOT_SIZE =1.00;
input double Buy_AT =00000.0000;
input double Sell_AT =00000.0000;
input double Tralling_InPoint =2000;
input double Take_Profit_At =0.0;
input double Stop_LOSE =0.0;
input group "Auto Trading"
input TradeAutoOption Trade_Auto =No;
input SYMBOL_ASK_O SYMBOL =Boom_Index_1000;
//--- input parameters
//+------------------------------------------------------------------+
//| Global expert object |
//+------------------------------------------------------------------+
CExpert ExtExpert;
CTrade Trade;
//+------------------------------------------------------------------+
//| Global expert object |
//+------------------------------------------------------------------+
//+-----------------------Function-----------------------------------+
void Start_Buy(double LOT_SIZE1 ,double Buy_From1 ,double Stop_LOSE1, double Take_Profit_At2){
double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK),_Digits);
if(Ask < Buy_From1){
Trade.BuyStop(LOT_SIZE1 ,Buy_From1,_Symbol,Stop_LOSE1,Take_Profit_At,ORDER_TIME_GTC, NULL , "Buying Started...\n ");
}
else if (Ask > Buy_From1)
{
Trade.BuyLimit(LOT_SIZE1 ,Buy_From1,_Symbol,Stop_LOSE1,Take_Profit_At,ORDER_TIME_GTC, NULL , "Buying Started...\n ");
}
else
{
string comment=StringFormat("\n\nError %d Is the Current Price" , Buy_From1 );
ChartSetString(0,CHART_COMMENT,comment);
}
};//function
void Start_Sell(double LOT_SIZE2 , double Sell_From2 , double Stop_LOSE2 , double Take_Profit_At2)
{
double Bid= NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
if(Bid > Sell_From2 )
{
Trade.SellStop(LOT_SIZE2 , Sell_From2 ,_Symbol,Stop_LOSE2 , Take_Profit_At2 , ORDER_TIME_GTC , "SEll Started...\n");
}
else if (Bid < Sell_From2)
{
Trade.SellLimit(LOT_SIZE2 , Sell_From2 ,_Symbol,Stop_LOSE2 , Take_Profit_At2 , ORDER_TIME_GTC , "SEll Started...\n");
}
else
{
string comment=StringFormat("\n\nError %d Is the Current Price" , Sell_From2 );
ChartSetString(0,CHART_COMMENT,comment);
}
};
void Chek_Typ(int Ordder_Type){
if(Ordder_Type == BUY)
{
Start_Buy(LOT_SIZE ,Buy_AT , Stop_LOSE , Take_Profit_At);
}
else
{
Start_Sell(LOT_SIZE , Sell_AT , Stop_LOSE , Take_Profit_At);
}
};
void SetVAlueOneTheChart(){
double ID = 1;
string comment=StringFormat("The Expert Working... %d" , ID );
ChartSetString(0,CHART_COMMENT,comment);
};
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
//-----------------------Initializing expert--------------------------------
//SetVAlueOneTheChart();
Comment("The Expert Working....");
Chek_Typ(Ordder_Type);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Function-event handler "tick" |
//+------------------------------------------------------------------+
void OnTick(void)
{
}
//+------------------------------------------------------------------+
//| Function-event handler "trade" |
//+------------------------------------------------------------------+
void OnTrade(void)
{
}
//+------------------------------------------------------------------+
//| Deinitialization function of the expert |
//+------------------------------------------------------------------+
void OnDeinit(const int reason )
{
if()
Trade_Type Ordder_Type =BUY;
double LOT_SIZE =1.00;
double Buy_AT =00000.0000;
double Sell_AT =00000.0000;
double Tralling_InPoint =2000;
double Take_Profit_At =0.0;
double Stop_LOSE =0.0;
ExtExpert.Deinit();
Print("The deinitialization occured_Error Number Is" , reason);
}
In an EA I'm writing a couple of integer values (some OrderTickects) into a bin file.
Then I have a TP/SL modification function that loops through active trades and applies the modifications. This function is called by each tick and opens the file and if the order ticket found in the file should ignore that order without modification.
The problem is that it successfully opens the file and reads it but only for the first time.
the rest of the time it gives me an error of 0.
I have checked everything as much as I could and tracked the issue with putting lots of prints until eventually, I am pretty sure that the problem is only the failure of the FileOpen function.
THIS HAPPENED ON TESTER. I'm not sure if it will happen on the live market as well or not, because, to catch the issue on live testing would be very hard with this EA.
I should add that every time that I opened the file, I also closed it.
My only guess is that maybe when I call the FileClose function before it closes the file successfully the next call of FileOpen arrives.
Can it be the reason?
I would highly appreciate any guidance or ideas.
Do you think I can trust opening the file in the live market?
Here are the related parts of the code.
Save function is called so less often, but IsBE_Done() is called by every tick if there are one or more active trades.
void Save(int ticket)
{
int handle = FileOpen("BE1.bin", FILE_BIN | FILE_WRITE | FILE_READ);
if(handle != INVALID_HANDLE)
{
FileSeek(handle, 0, SEEK_END);
FileWriteInteger(handle, ticket);
//---
FileClose(handle);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool IsBE_Done(int ticket)
{
int handle = FileOpen("BE1.bin", FILE_BIN | FILE_WRITE | FILE_READ);
if(handle != INVALID_HANDLE)
{
FileSeek(handle, 0, SEEK_SET);
while(!FileIsEnding(handle))
{
int val = FileReadInteger(handle);
if(ticket == val)
return true;
}
//---
FileClose(handle);
}
//---
return false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void TPSL_Modification()
{
//---
if(!Modifications)
return;
//---
for(int i = OrdersTotal() - 1; i >= 0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
continue;
//---
if(OrderMagicNumber() != MAGICMA || OrderSymbol() != _Symbol)
continue;
//---
if(IsBE_Done(OrderTicket())) //====>>> This is what opens the file
continue;
//---
I have a MetaTrader Terminal 4 logged into a demo account.
I have written and compiled my first Expert Advisor.
I am able to debug it on a live chart, so working fine. I would like to debug it though on historical data. In the MetaEditor the Debug>Start on history data is grey out though.
Also when running the strategy tester my break points never get hit, I put the break point on the first line in the OnTick() function, so it should get hit in my understanding.
Is this because I have a demo account? If not how can I debug my script on historical data?
update code below
#property strict
//+------------------------------------------------------------------+
//| Includes and object initialization |
//+------------------------------------------------------------------+
#include <book_examples\Trade.mqh>
CTrade Trade;
CCount Count;
#include <book_examples\Timer.mqh>
CTimer Timer;
CNewBar NewBar; // keeps track of timestamp of current bar & allows us to
determine when a new bar has opened so prevents orders being opened intrabar
#include <book_examples\TrailingStop.mqh>
#include <book_examples\MoneyManagement.mqh>
#include <book_examples\Indicators.mqh>
//+------------------------------------------------------------------+
//| Input variables |
//+------------------------------------------------------------------+
// left out to keep the post short
//+------------------------------------------------------------------+
//| Enum |
//+------------------------------------------------------------------+
enum trade_action
{
NO_ACTION = 0,
LONG = 1,
SHORT = 2,
EXIT_TRADE = 3
};
//+------------------------------------------------------------------+
//| Global variable and indicators |
//+------------------------------------------------------------------+
int gBuyTicket, gSellTicket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Set magic number
Trade.SetMagicNumber(101);
Trade.SetSlippage(10);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Check for bar open
bool newBar = true; // I put a breakpoint on this line
int barShift = 0;
if(TradeOnBarOpen == true)
{
newBar = NewBar.CheckNewBar(_Symbol,_Period);
barShift = 1;
}
// Trading
if(newBar == true)
{
// Money management
double lotSize = FixedLotSize;
if(UseMoneyManagement == true)
{
lotSize = MoneyManagement(_Symbol,FixedLotSize,RiskPercent,StopLoss);
}
trade_action action = calculate_signal();
// Open buy order
if(action == LONG)
{
// close sell orders
Trade.CloseAllSellOrders();
// check if we already have an open buy trade
int open_buy = Count.Buy();
if(open_buy == 0)
{
// no current existing buy position so enter
gBuyTicket = Trade.OpenBuyOrder(_Symbol,lotSize);
ModifyStopsByPoints(gBuyTicket,StopLoss,TakeProfit);
}
}
// Open sell order
else if(action == SHORT)
{
Trade.CloseAllBuyOrders();
// check if we already have an open sell trade
int open_sell = Count.Sell();
if(open_sell == 0)
{
// no current existing sell position so enter
gSellTicket = Trade.OpenSellOrder(_Symbol,lotSize);
ModifyStopsByPoints(gSellTicket,StopLoss,TakeProfit);
}
}
}
}
trade_action calculate_signal()
{
trade_action action = NO_ACTION;
// now calculate trade logic
if (some_value > some_threshold)
{
action = LONG;
}
else if (some_value < some_threshold)
{
// enter short position
action = SHORT;
}
return action;
}
Q : "Is this because I have a demo account?"
No.
Q : "If not how can I debug my script on historical data?"
In the MT4 (as-is-2020/06) you still can implement, if in a need to have such, your own "debugging"-Inspector/Monitor-agent tool to get executed during the StrategyTester-mode of the run of the MQL4 compiled-EA.
The MT4's StrategyTester is a BackTesting tool, not an (emulated)live-market Simulator-and-Debugger, it only operates the EA in synthetic(accelerated|slowed-down)-time, using a controlled-flow of synthetic-QUOTE-message(s), emulated for a given trading instrument and TimeFrame.
So if I wanted an EA in MQL4 that took the open price and when current price was 10 pips below the open it places a buy order and when it was 10 pips above the open it sold. Only one order at a time and the open changed daily.
Q1: How could that run unstopped?
Q2: Would that even be profitable?
I know this is simple for some people to write but for me it's depressing.
A1: the simplest part ...
The MQL4 Expert Advisor type-of-code's execution can be principally run unstopped, supposing the execution engine, the MetaTrader Terminal 4, is being run in a nonstop mode. While there still remain the weekends available for service & maintenance tasks, the EA code, per se can be operated infinitely long, state-fully with an automated re-entrant safe re-launch self-protection ( OnInit(){...} + OnDeinit(){...} ).
#property copyright "Copyright © 1987-2016 [MS]"
#property link "nowhere.no"
#property version "0.00"
#property strict
extern int minDist2XTO = 10; // A minimum Distance To XTO
bool aGlobalMUTEX_LOCKED = False; // LOCK "only one order at a time"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{ // on-launch intialisation tasks go here:
return( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit( const int reason )
{ // pre-exit sanitisation tasks go here:
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{ // MAIN: this is being executed upon each anFxMarketEVENT's arrival
// GoLONG();
// GoSHORT();
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{ // back-testing utility calculation functions go here:
double retVal = 0.0;
return( retVal );
}
//+------------------------------------------------------------------+
void GoLONG()
{ // SELF-CONTROLLABLE ( might even get concurrently run in parallel to GoSHORT on dual resources )
// -------------------------------------------------------------------------------------------------------
static bool aNewBarEVENT = FALSE;
static int aLastBAR = EMPTY,
aCurrBAR = EMPTY;
static double GoLONG_LEVEL = EMPTY;
// -------------------------------------------------------------------------------------------------------
// TEST A STATE-SHIFT
RefreshRates();
aCurrBAR = iBars(_Symbol, PERIOD_D1 );
if ( aLastBAR != aCurrBAR )
{ aLastBAR = aCurrBAR; // .SET
aNewBarEVENT = TRUE; // .FLAG
// ----------------------- // .RESET in-BAR-registers
GoLONG_LEVEL = NormalizeDouble( iOpen( _Symbol, PERIOD_D1, 0 )
- minDist2XTO * _Point
);
// ----------------------
}
else
{ aNewBarEVENT = FALSE; // !FLAG
}
if ( !aGlobalMUTEX_LOCKED
&& Ask <= GoLONG_LEVEL
)
{
// XTO ... // .XTO
if ( success ) aGlobalMUTEX_LOCK = True;
}
}
//+------------------------------------------------------------------+
void GoSHORT()
{ // SELF-CONTROLLABLE ( might even get concurrently run in parallel to GoLONG on dual resources )
...
..
.
}
A2:
This question can be addressed quantitatively. Your trading idea can be tested and validated on the real-market data, so as to provide a reasonable amount of observations that either support or limit the expected performance expectations.
Without quantitative data from adequate TimeDOMAIN span of the market seasonality irregularities, the question cannot have a reasonably supported quantitative answer ( except for just an opinion ).
This goes far beyond a StackOverflow format of Q/A, but in principle back-testing ( with a support of an inbuilt mechanism of double OnTester(){...} post-processing facility ) and forward-testing ( with a support of demo-account forward runs ) are both being used in quant modelling, before any real trading strategy is ever exposed to execute any real market-risk.
Is there any support of OpenCV graphics library is available for Windows Phone 8 and Windows 8. I made a search on Google but didn't find any resource related with OpenCV to connect with Windows Phone 8 / Windows 8. If any of you know more about this please help me, and provide some link to reach the library.
This is the latest information what I get from OpenCV team.
OpenCV development team is working on port for Windows RT. Here is current development branch for WinRT(https://github.com/asmorkalov/opencv/tree/winrt). You can build it for ARM using Visual Studio Express for Windows 8 and Platform SDK.
Open Visual Studio development console.
Setup environment for cross compilation by command "C:\Program Files(x86)\Microsoft
Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
cd <opencv_source_dir>/platforms/winrt/
run scripts/cmake_winrt.cmd
run ninja
Alternatively you can use nmake instead ninja. You need to edit cmake_winrt.cmd and change project generator fro -GNinja to -G "NMake Makefiles". Only algorithmic part of the library is supported now, no tbb, no UI, no video IO.
Please check the below given URL from more details.
http://answers.opencv.org/question/9847/opencv-for-windows-8-tablet/?answer=9851#post-id-9851
By windows-8, I guess you mean winRT ? AFAIK, there is no official port to winRT. You need to compile it by yourself as a Win8 Store DLL for instance, so that you can reference it from a Win8 Store Application.
Just start by opencv-core, then add the lib you need, one by one, because all the components will not be able to compile (for instance, opencv-highgui is highly dependant on Windows API which is not fully compatible with Win8 Store Apps).
You'll also need to code by yourself some Win32 methods used by OpenCV and not accessible from Win8 App like GetSystemInfo(), GetTempPathA(), GetTempFileNameA() and all methods related to thread local storage (TLS).
I've been able to use a small subset of OpenCV in WinRT by compiling opencv_core, opencv_imgproc and zlib, as 3 seperate static libs. I've added one another, called opencv_winrt, that contains only the two following files:
opencv_winrt.h
#pragma once
#include "combaseapi.h"
void WINAPI GetSystemInfo(
_Out_ LPSYSTEM_INFO lpSystemInfo
);
DWORD WINAPI GetTempPathA(
_In_ DWORD nBufferLength,
_Out_ char* lpBuffer
);
UINT WINAPI GetTempFileNameA(
_In_ const char* lpPathName,
_In_ const char* lpPrefixString,
_In_ UINT uUnique,
_Out_ char* lpTempFileName
);
DWORD WINAPI TlsAlloc();
BOOL WINAPI TlsFree(
_In_ DWORD dwTlsIndex
);
LPVOID WINAPI TlsGetValue(
_In_ DWORD dwTlsIndex
);
BOOL WINAPI TlsSetValue(
_In_ DWORD dwTlsIndex,
_In_opt_ LPVOID lpTlsValue
);
void WINAPI TlsShutdown();
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
opencv_winrt.cpp
#include "opencv_winrt.h"
#include <vector>
#include <set>
#include <mutex>
#include "assert.h"
void WINAPI GetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
{
GetNativeSystemInfo(lpSystemInfo);
}
DWORD WINAPI GetTempPathA(DWORD nBufferLength, char* lpBuffer)
{
return 0;
}
UINT WINAPI GetTempFileNameA(const char* lpPathName, const char* lpPrefixString, UINT uUnique, char* lpTempFileName)
{
return 0;
}
// Thread local storage.
typedef std::vector<void*> ThreadLocalData;
static __declspec(thread) ThreadLocalData* currentThreadData = nullptr;
static std::set<ThreadLocalData*> allThreadData;
static DWORD nextTlsIndex = 0;
static std::vector<DWORD> freeTlsIndices;
static std::mutex tlsAllocationLock;
DWORD WINAPI TlsAlloc()
{
std::lock_guard<std::mutex> lock(tlsAllocationLock);
// Can we reuse a previously freed TLS slot?
if (!freeTlsIndices.empty())
{
DWORD result = freeTlsIndices.back();
freeTlsIndices.pop_back();
return result;
}
// Allocate a new TLS slot.
return nextTlsIndex++;
}
_Use_decl_annotations_ BOOL WINAPI TlsFree(DWORD dwTlsIndex)
{
std::lock_guard<std::mutex> lock(tlsAllocationLock);
assert(dwTlsIndex < nextTlsIndex);
assert(find(freeTlsIndices.begin(), freeTlsIndices.end(), dwTlsIndex) == freeTlsIndices.end());
// Store this slot for reuse by TlsAlloc.
try
{
freeTlsIndices.push_back(dwTlsIndex);
}
catch (...)
{
return false;
}
// Zero the value for all threads that might be using this now freed slot.
for each (auto threadData in allThreadData)
{
if (threadData->size() > dwTlsIndex)
{
threadData->at(dwTlsIndex) = nullptr;
}
}
return true;
}
_Use_decl_annotations_ LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex)
{
ThreadLocalData* threadData = currentThreadData;
if (threadData && threadData->size() > dwTlsIndex)
{
// Return the value of an allocated TLS slot.
return threadData->at(dwTlsIndex);
}
else
{
// Default value for unallocated slots.
return nullptr;
}
}
_Use_decl_annotations_ BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
ThreadLocalData* threadData = currentThreadData;
if (!threadData)
{
// First time allocation of TLS data for this thread.
try
{
threadData = new ThreadLocalData(dwTlsIndex + 1, nullptr);
std::lock_guard<std::mutex> lock(tlsAllocationLock);
allThreadData.insert(threadData);
currentThreadData = threadData;
}
catch (...)
{
if (threadData)
delete threadData;
return false;
}
}
else if (threadData->size() <= dwTlsIndex)
{
// This thread already has a TLS data block, but it must be expanded to fit the specified slot.
try
{
std::lock_guard<std::mutex> lock(tlsAllocationLock);
threadData->resize(dwTlsIndex + 1, nullptr);
}
catch (...)
{
return false;
}
}
// Store the new value for this slot.
threadData->at(dwTlsIndex) = lpTlsValue;
return true;
}
// Called at thread exit to clean up TLS allocations.
void WINAPI TlsShutdown()
{
ThreadLocalData* threadData = currentThreadData;
if (threadData)
{
{
std::lock_guard<std::mutex> lock(tlsAllocationLock);
allThreadData.erase(threadData);
}
currentThreadData = nullptr;
delete threadData;
}
}
And I modify the file cvconfig.h: I've commented out every #define, except PACKAGE* and VERSION, and I added #include "opencv_winrt.h" at the end.
Just a hint - there is a C# wrapper for OpenCV called EmguCV (http://www.emgu.com/wiki/index.php/Main_Page), by looking at the forum posts I see that there is some activity towards using it on Windows 8 but it's hard to tell if it's now working since the posts claiming issues are quite old. I'd suggest you just give it a try and see if this C# wrapper is able to run on Windows Phone 8, I think it should definitely run on Windows 8.