Page 1 of 1

Programming questions

Posted: 26 Jul 2013 19:44
by barbara
Hello,

I have three questions when trying to program my strategy and hope you can help me:

1.
from what I understood: with classical sentimentor we can generate signals and with stop sentimentors we can handle the stop loss of opening trade.
If I would like to have a strategy to open the trade and at the same time to place the stop loss, can I do that in one program? (without using Trade Guard)
Do you have any example for that?

2.
MarketPosition() function can only be used in stop sentimentors. If in a classical sentimentor I would like to know the current position, how can I do that?

3.
The new trade is based on the previous closed trade (with the same symbol). How can I get the information of the previous trade, for example its type (buy or sell), its profit and loss, its size etc?

Thank you and best regards,

Re: Programming questions

Posted: 26 Jul 2013 20:45
by WHS Support
Hello Barbara,

1) You can also integrate a normal Stop-Loss or Take Profit into your strategy. You can for example use the fixed stop and the profit target. Once you enter into a position this orders will be placed (similar like tradeguard would do).
The MACD triple Strategy uses this for example: http://www.whselfinvest.com/en/trading_ ... Triple.php

2) You can not do this. Running your system the Metasentimentor checks the position. So for example the strategy should be long, but (for whatever reason) you are flat or short, it will bring you into the position according to the system.

3) Those parameters can not be used for a strategy.

Kind regards
Dominic
WHS

Re: Programming questions

Posted: 29 Jul 2013 13:19
by barbara
Hello Dominic,

Thank you for your reply.
I didn't find the template study "WHS MACD Triple" as explained in the article. I attached a screenshot, Does the MACD.dys work?
The strategy may not be programmed as a Sentimentor in the Express folder, it can also be programmed as a study?

Thank you,

Re: Programming questions

Posted: 29 Jul 2013 14:36
by WHS Support
Dear Barbara,

You need to open it with the icon on top of the chart:
MACD Triple.png
It is just an example because this strategies uses the fixed stop and profit target.

Kind regards
Dominic
WHS

Re: Programming questions

Posted: 30 Jul 2013 00:02
by barbara
Hi Dominic,

thanks, we progress ;)
But I can not find a way to see the code in an editor...

If I look at the file "WHS MACD Triple.dys", it is looking like a compiled code.

Thanks

Re: Programming questions

Posted: 30 Jul 2013 16:20
by barbara
Hi Dominic,

can you please confirm we can't have access to the source code of WHS MACD Triple to learn how to integrate a normal Stop-Loss or Take Profit into the strategy ?

Thanks,

Re: Programming questions

Posted: 30 Jul 2013 18:07
by WHS Support
Hello Barbara,

The concept of strategies / indicators in FutureStation is a bit different than in other platforms (e.g. MetaTrader 4). The strategy file (.DYS) is only a container file which includes the actual indicators (in FutureStation also called Sentimentors), objectives (TakeProfit) and Stop loss. In addition it can include certain trading time filters, blockers, exit conditions etc...
Hence you cannot open a .DYS file externally as it's not needed. If the DYS file isn't encrypted you can always open the strategy inside the trading platform and you can see all the indicators, filters, brackets etc. that are included (and therefore able to modify, change or replace them):
MACD.jpg
So here there is no real source code despite the basic code of the (3) MACD(s) which is not visible because of the fact that it's a standard indicator. But if you are interested in the MACD code you can reproduce it in Express using this formula:

Express MACD

Vars

Series fastMA, slowMA, Signalline, MACD, Zeroline(0);

Input
$slowEMA(1, 200, 26),
$fastEMA(1, 200, 12),
$smooth(1, 200, 9);

Calculation
If IsFirstbar() then begin
ExpMovingAverage(c, fastMA, $fastEMA);
ExpMovingAverage(c, slowMA, $slowEMA);
end
MACD = fastMA-slowMA;
If IsFinalBar() then ExpMovingAverage(MACD, Signalline, $smooth);

Interpretation
begin
end

plot (MACD, lightmagenta, 1);
plot (Signalline, darkblue, 1);
plot (zeroline, grey, 1);

--

Kind regards,
Timo
WH SelfInvest