CHECK THIS OUT: Real-time position checker, code included!

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
jondo
Posts: 9
Joined: 17 Jul 2015
Has thanked: 1 time
Been thanked: 2 times

CHECK THIS OUT: Real-time position checker, code included!

Postby jondo » 07 Aug 2015

Hello,

I made a small utility which should help me to monitor strategies in real time. Please, I would appreciate any comments or recommendations.

How it's supposed to work:

1.) Add to your strategies following setting up of GVs:

GVSetNamedFloat(Getstrategyname+"_TT", Totaltrades);
GVSetNamedFloat(Getstrategyname+"_MP", Marketposition );
GVSetNamedFloat(Getstrategyname+"_BS", MarketPosition_at_Broker_for_The_Strategy );
GVSetNamedFloat(Getstrategyname+"_MP_B", MarketPosition_at_Broker);
GVSetNamedFloat(Getstrategyname+"_CC", CurrentContracts);

2.) Inputs to indicator are names of strategies which we would like to monitor on appropriate symbol. Indicator should pain bars based on position on chart, also it should alert user when following condition are not met:

I.) Internal check (Check Strategy Side) = no global variables needed
If TT = TT[1] and MP_BS <> MP[1]
then MisMatch = TRUE else MisMatch = FALSE;

II.) External check (Monitor number of contracts on symbol) = get numbers of contracts from each strategy and their summation should be equal to "MarketPosition_at_Broker" (MP_B).
Summ = CC1 + CC2 + CC3;
If Summ <> MP_B
then MisMatch = TRUE else MisMatch = FALSE;


Further notes:
* Using brokers data, so no further strategies should run on account for that symbol, also wont be working in back-test
* Can be easily coded for more strategies than 3 on symbol
* Working only for one symbol
* Not tested for scaling
* The most problematic part I think is a variable "flag" which I was pushed to use in order to minimize the number of warnings per bar due inside bars. As other chart will have a signals in different times, variables can change asynchronously with current chart, so that can cause problems and "falsely" trigger alert conditions. Any tip how to work it out and not to eliminate other ticks on bar appreciated!
* I tried the code only on range bars.


I appreciate any suggestion or potential problems notice (different conditions, potential threads, perhaps ideas when this condition do not work etc.).


Thank you,
John
Attachments
Checker_15_08_07.pla
(14.7 KiB) Downloaded 131 times

jondo
Posts: 9
Joined: 17 Jul 2015
Has thanked: 1 time
Been thanked: 2 times

UPDATE

Postby jondo » 11 Aug 2015

Please find checker indicator with random strategy to illustrate how GV should be defined...

Code remakes, because of function "CurrentContract" return absolute number of contracts not like MP_at_broker function which returns +/- based on position.

Please, do not forget to change inputs in indicator "name and other" to defined name in strategy! In this concrete example, name of strategy to start downloading appropriate GV is: "name+_TF_Rand". So get it working the input in indicator must be "TS_TF_Rand". That is going to work only for one strategy on symbol. If you want to include other strategies, other strategies must also save position info and names of those variables must be set in inputs of CHECKER indicator.

Any remarks appreciated, thank you.
Attachments
CHECKER_2_bar.pla
(22.24 KiB) Downloaded 138 times


Return to “User Contributed Studies and Indicator Library”