Libraries: Virtual

 

Virtual:

Virtual trading environment

Virtual

Author: fxsaber

 
May I know what TS stands for?
 
Zee Zhou Ma:
May I know what TS stands for?

Trading Strategy.


Last version.

 

Does the library help to handle multiple TS/EA within 1 trading account?


E.g. Funds in 1 account is 10,000 USD.

You want to allocate 7,000 for EA 1 and 3,000 for EA 2.

Individual EA to stop when they depleted their respective portion of the account and not eat into the other EA's allocation

 
Keith Long:

Does the library help to handle multiple TS/EA within 1 trading account?


E.g. Funds in 1 account is 10,000 USD.

You want to allocate 7,000 for EA 1 and 3,000 for EA 2.

Individual EA to stop when they depleted their respective portion of the account and not eat into the other EA's allocation

Yes, this is possible to program.

 

What do you think about Stop Limit Orders? It is not implemented.

Is there a workaround for this with limit orders?

 
Zee Zhou Ma:

What do you think about Stop Limit Orders? It is not implemented.

Is there a workaround for this with limit orders?

This is an artificial order type. I never needed him. Therefore did not implement.

 
fxsaber:

This is an artificial order type. I never needed him. Therefore did not implement.

I see. Thanks.. that is a good feedback. :D

 
Zee Zhou Ma:

Hi fxsaber,

Do you have any way to ensure the code will go into this "VIRTUAL::SelectOrders" condition check? 

In the code fragment below, I will always go into VirtualOrderSend 3

I have many include files and I have difficulty trying to force the code to go into the procedure after the  "VIRTUAL::SelectOrders" condition check.

But running your example file is okay.

Add

#include <fxsaber\Virtual\Virtual.mqh> // Virtual trading environment

before many include.


Show the source, which does not work as you would like. And write what should be.

 

Hi fxsaber,


Amazing and interresting work.

I just tried to compare results from virtual to real TS and so add the following lines in the DeInit procedure :


void OnDeinit(const int reason)
{
  VIRTUAL::SelectByHandle();
  PrintFormat("(%s-%s)::%s - Initial deposit=%.2f, Balance=%.2f, Equity=%.2f, Profit=%G, Trades=%d", _Symbol, EnumToString(_Period), "Real", 0,AccountBalance(), AccountEquity(), AccountProfit(), OrdersHistoryTotal());
  VIRTUAL::SelectByHandle(handle);
  PrintFormat("(%s-%s)::%s - Initial deposit=%.2f, Balance=%.2f, Equity=%.2f, Profit=%G, Trades=%d", _Symbol, EnumToString(_Period), "Virtual", 0,AccountBalance(), AccountEquity(), AccountProfit(), OrdersHistoryTotal());
                                                                        
  Comment("");
}

And as a result, I cannot get the correct value for Profit (AccountProfit()). It seems Deposit is in the first 'Order' and is not correctly taken in consideration, also in the trades count.



What I am doing wrong?

Best regards,

och

 
och:

I just tried to compare results from virtual to real TS and so add the following lines in the DeInit procedure :

 void OnDeinit ( const int reason)
{
  VIRTUAL::SelectByHandle();
   PrintFormat ( "(%s-%s)::%s - Initial deposit=%.2f, Balance=%.2f, Equity=%.2f, Profit=%G, Trades=%d" , _Symbol , EnumToString ( _Period ), "Real" , 0 ,AccountBalance(), AccountEquity(), AccountProfit(), OrdersHistoryTotal());
  VIRTUAL::SelectByHandle(handle);
  VIRTUAL::Stop();
   PrintFormat ( "(%s-%s)::%s - Initial deposit=%.2f, Balance=%.2f, Equity=%.2f, Profit=%G, Trades=%d" , _Symbol , EnumToString ( _Period ), "Virtual" , 0 ,AccountBalance(), AccountEquity(), AccountProfit(), OrdersHistoryTotal());
                                                                        
   Comment ( "" );
}
Reason: